Q: How to implement persistent storage with overlayroot and UBIFS on NAND flash?
Answer
For NAND-based systems (IoT gateways industrial controllers): use UBIFS on top of UBI (Unsorted Block Images) for wear-leveling and bad block management. Create: ubiattach /dev/ubi_ctrl -m then ubimkvol /dev/ubi0 -N persistent -s . Mount: mount -t ubifs ubi0:persistent /data. For the root filesystem use SquashFS + overlay: mount -t squashfs /dev/root /rom then mount -t overlayfs overlay -o lowerdir=/rom,upperdir=/data/root,workdir=/data/work /overlay. Write a custom systemd service to orchestrate this at boot. Monitor NAND wear: check /sys/class/mtd/mtd0/keep_count. UBIFS journals writes – for high-write applications use a separate UBIFS volume for /var/log.
Filed under: FAQ