Search topics...
Embedded LinuxUserspace & Build Systemsadvanced

Which filesystem would you use on raw NAND flash and why not ext4?

0 upvotes
Practice with AISoon

For raw NAND flash, you should use UBIFS (on top of the UBI layer) or JFFS2. UBIFS is the modern choice — it provides wear leveling, transparent compression, write-back caching, and scales well to large flash sizes (multiple gigabytes). UBI (Unsorted Block Images) sits between the MTD layer and UBIFS, handling wear leveling, bad block management, and logical-to-physical block mapping across the entire flash chip.

ext4 cannot be used on raw NAND flash because ext4 was designed for block devices — storage where every block is identical, rewritable, and reliable. Raw NAND flash has fundamentally different characteristics: blocks must be erased before rewriting (and erasure is a slow, whole-block operation), each block has a limited erase cycle count (1K-100K depending on the technology), and blocks can go bad during the lifetime of the device. ext4 has no mechanism for wear leveling (it would repeatedly rewrite the same blocks — the superblock, journal, and metadata — wearing them out rapidly) and no bad block management.

The exception is eMMC and SD cards, which are NAND flash with a built-in Flash Translation Layer (FTL) that handles wear leveling and bad block management internally, presenting a standard block device interface. On eMMC, ext4 is perfectly appropriate — and commonly used. The key distinction in an interview is recognizing that "NAND flash" can mean raw NAND (requiring UBI/UBIFS or JFFS2) or managed NAND with an FTL (eMMC/SD, where ext4 works fine). JFFS2 is simpler than UBIFS but has long mount times on large partitions because it scans the entire flash at mount, making it suitable only for small partitions (configuration storage, for example).

Source: Embedded Linux Q&A