Resizing mtd partition
ricard.wanderlof at axis.com
Mon Feb 23 00:14:02 PST 2015
On Sun, 22 Feb 2015, Alexander Aronsky wrote:
> Hi everyone,
> I have to resize an existing mtd partition on a NOR flash of an embedded
> device (PPC architecture) without losing the data on this partition.
> To be more specific, I have /dev/mtd0 and /dev/mtd1 devices on my flash,
> and I want to increase the size of the file system mounted on /dev/mtdblock0
> at the expense of the one on /dev/mtdblock1. For example, eliminate the
> /dev/mtd1 altogether and give the /dev/mtd0 all the available space on the
> What is the proper way to do it?
I don't think there is a 'proper' way, i.e. a resize application.
However, if the file system on the partition is jffs2, then I believe one
could do the following:
- Unmount /dev/mtd0 (and /dev/mtd1)
- Erase /dev/mtd1
- Rewrite the partitioning info so that /dev/mtd0 now includes both
- Mount /dev/mtd0 .
When /dev/mtd0 is mounted, jffs2 will now see that the size is
larger. Since there is no global file system information within a jffs2
file system, it will see the newly erased space as unused when scanning
the partition during the mount operation.
If you can't unmount /dev/mtd0 because it is the root file system,
you could do most operations with /dev/mtd0 mounted, and a reboot in
- Unmount /dev/mtd1.
- Erase /dev/mtd1.
- Rewrite partitioning info so that /dev/mtd0 new includes both old
- Reboot the system, when it starts it will use the new larger
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30
More information about the linux-mtd