State of read-only filesystems in NAND / MTD bad blocks handling when reading

Ricard Wanderlof ricard.wanderlof at axis.com
Wed May 2 03:42:58 EDT 2012


On Wed, 2 May 2012, Thilo Fromm wrote:

> > I'm on a TI embedded system on kernel 2.6.37. Could you please fill me
> > in on the current state of readonly filesystems living in NAND flash
> > w/ bad blocks? I've found several discussions on linux-mtd over the
> > years[1][2][3] but none seemed to have reached a conclusion. The point
> > is this, while both bootloader and nandwrite will happily skip bad
> > blocks encountered upon image write the MTD driver's read function
> > will not.
> >
> > This means I can safely write the root fs into a MTD partition, but I
> > cannot read it back safely (let alone mount it). Is there a generic
> > way to have the MTD driver auto-skip bad blocks? What happened to
> > MTD_BLOCK_RO_BBFREE?
> >
> > [1] http://lists.infradead.org/pipermail/linux-mtd/2004-May/009672.html
> > [2] http://lists.infradead.org/pipermail/linux-mtd/2004-May/009683.html
> > [3] http://lists.infradead.org/pipermail/linux-mtd/2006-November/016835.html
> >
> 
> Is no-one else using read-only filesystems in NAND flash w/ bad blocks
> in it? Do I miss something obvious? Help?

It is true that read-only file systems such as cramfs cannot in the 
general case operate on nand flash because of the bad blocks issue.

One way is to use a file system intended for flashes, but mount it 
read-only. I.e. use a jffs2 filesystem, mounted readonly.

Or, let UBI handle the flash, and use ubifs in a static volume, which 
means it will be non-writable. Last time I checked it wasn't possible to 
use file systems such as cramfs on UBI, because UBI did not supply a block 
device which is required by cramfs. I seem to remember some patch to add 
block devices to UBI, not sure what the state of that is.

A slightly different solution is to have the root file system as an 
initramfs, stored with the kernel. That way, you unpack a large 
kernel+rootfs image to memory and run it there. It tends to be a bit 
wasteful on both flash and RAM though. Also, the file system is always 
writable, but of course any writes are not mirrored back to the flash.

/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



More information about the linux-mtd mailing list