Table of Contents

Rootfs notes

Rootfs in FLASH (UBIFS)

The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:

# mtdinfo -a -u

Count of MTD devices:           4
Present MTD devices:            mtd0, mtd1, mtd2, mtd3
Sysfs interface supported:      yes

mtd0
Name:                           data
Type:                           nor
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size:                  1 byte
Character device major/minor:   90:0
Bad blocks are allowed:         false
Device is writable:             true
Default UBI VID header offset:  64
Default UBI data offset:        128
Default UBI LEB size:           130944 bytes, 127.9 KiB
Maximum UBI volumes count:      128

To format FLASH partition and put UBIFS image into it the following command sequence may be used:

# ubiformat /dev/mtd0

ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes
libscan: scanning eraseblock 767 -- 100 % complete  
ubiformat: 768 eraseblocks have valid erase counter, mean value is 2
ubiformat: formatting eraseblock 767 -- 100 % complete  

# ubiattach -p /dev/mtd0

 UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)

# ubimkvol /dev/ubi0 -m -N rootfs

 Set volume size to 100041216
 Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name "rootfs", alignment 1

# ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs

# mount -t ubifs /dev/ubi0_0 /mnt

 ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs

Further reading: