</>EmbeddedInterview

Which filesystems are used on embedded flash?

MediumEmbedded Linux & Boot

Short answer: It depends on the flash type. On raw NAND/NOR (an MTD device without its own controller) use UBIFS on top of UBI (or JFFS2 on small NOR), because the filesystem must handle wear levelling and bad blocks. On managed flash (eMMC, SD, UFS, SSD) the controller does that, so use ext4 or F2FS. For a read-only root use SquashFS or EROFS.

Raw flash vs managed flash

Raw NAND/NOR (MTD) Managed (eMMC, SD, UFS)
Interface /dev/mtdN, erase blocks, pages, OOB area /dev/mmcblkN, normal block device
Bad blocks, ECC, wear levelling software (UBI, MTD, NAND driver) controller firmware (FTL)
Filesystems UBIFS (on UBI), JFFS2, YAFFS2 ext4, F2FS, (btrfs)

Filesystem guide

  • UBIFS: journaling, compression, scales to large NAND, fast mount. UBI below it spreads erases across the whole flash and manages bad blocks and volumes.
  • JFFS2: older log-structured filesystem for small NOR; mount time grows with size.
  • ext4: the default on eMMC/SD; mature, journaling. Use data=ordered (the default) and avoid unnecessary writes.
  • F2FS: designed for flash-based block devices; can reduce write amplification on cheap SD/eMMC.
  • SquashFS / EROFS: compressed and read-only; the root image cannot be corrupted by power loss. EROFS is newer, faster to read, and used by Android.
  • tmpfs: RAM-based, for /tmp, /run and logs that do not need to survive reboot.
  • OverlayFS: a writable layer (on a data partition or tmpfs) over a read-only root.

A robust layout used by many products

boot partition       (FAT or raw)   bootloader, kernel, DTB
rootfs A / rootfs B  (SquashFS/EROFS or ext4 mounted ro)   A/B update slots
data                 (ext4/F2FS or UBIFS)                  config, logs, user data

Protecting against power loss and wear: keep the root read-only, write data with fsync() and the write-temp-then-rename() pattern, limit logging to flash (journald with Storage=volatile, or rate limits), avoid atime updates (noatime), and monitor eMMC health (mmc extcsd read gives the life-time estimate).