Resizing mtd partition

Alexander Aronsky alexander_ar at rad.com
Mon Feb 23 00:59:09 PST 2015


> -----Original Message-----
> From: Ricard Wanderlof [mailto:ricard.wanderlof at axis.com]
> Sent: 23/02/2015 10:14
> To: Alexander Aronsky
> Cc: linux-mtd at lists.infradead.org
> Subject: Re: Resizing mtd partition
> 
> 
> 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 flash.
> >
> > 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
>   partitions.
> - 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
> between:
> 
> - Unmount /dev/mtd1.
> - Erase /dev/mtd1.
> - Rewrite partitioning info so that /dev/mtd0 new includes both old
>   partitions.
> - Reboot the system, when it starts it will use the new larger
>   /dev/mtd0 .
> 
> /Ricard
> --
> 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

Thank you very much, Ricard!

Only one more detail re. the second scenario you suggest:  what do you mean
by "rewrite partitioning info"?  I was just thinking of rebooting with another
device tree blob containing the desired partitioning info.  Is that going to work
or there is something else to it?

Thanks and best regards,
A.




More information about the linux-mtd mailing list