Unsorted Block Images File System

Linux: UBIFS host tools

UBIFS filesystems images can be created using mkfs.ubifs

  • mkfs.ubifs -m 4096 -e 258048 -c 1000 -r rootfs/ ubifs.img
    • -m 4096, minimal I/O size (see /sys/class/mtd/mtdx/writesize).
    • -e 258048, logical erase block size (smaller than PEB size, can be found in the kernel log after running ubiattach)
    • -c 1000, maximum size of the UBI volume the image will be flashed into, in number of logical erase blocks. Do not make this number unnecessary big, otherwise the UBIFS data structures will be bigger than needed and performance will be degraded. Details: http://linux-mtd.infradead.org/faq/ubifs.html#L_max_leb_cnt ▶ Once created ▶ Can be written to a UBI volume from the target using ubiupdatevol ▶ Or, can be included in a UBI image (using ubinize on the host)

Linux: UBIFS target tools

No specific tools are required to manipulate a UBIFS filesystem

  • Mounting a UBIFS filesystem is done with mount: mount -t ubifs :
  • Example: mount -t ubifs ubi0:data /data

Linux: UBI image creation workflow

Linux: Using a UBIFS filesystem as root filesystem

You just have to pass the following information on the kernel command line:

  • ubi.mtd=1 Attach /dev/mtd1 to the UBI layer and create ubi0
  • rootfstype=ubifs root=ubi0:rootfs Mount the rootfs volume on ubi0 as a UBIFS filesystem
  • Example: rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs

how to boot on a UBIFS filesystem

In U-Boot:

  • Define partitions: setenv mtdids ... setenv mtdparts ...
  • Define the base Linux kernel bootargs, specifying booting on UBIFS, the UBI volume used as root filesystem, and the MTD partition attached to UBI. Example: setenv bootargs_base console=ttyS0 rootfstype=ubifs root=ubi0:rootfs ubi.mtd=2 ...
  • Define the boot command sequence, loading the U-Boot partition definitions, loading kernel and DTB images from UBI partitions, and adding mtdparts to the kernel command line. Example: setenv bootcmd 'mtdparts; ubi part UBI; ubi readvol 0x81000000 kernel; ubi readvol 0x82000000 dtb; setenv bootargs ${bootargs_base} ${mtdparts}; bootz 0x81000000 - 0x82000000'

Linux: Block emulation layers

  • Sometimes we need block devices to re-use existing block filesystems, especially read-only ones like SquashFs
  • Linux provides two block emulation layers:
    • mtdblock: block devices emulated on top of MTD devices
    • ubiblock: block devices emulated on top of UBI volumes

Linux: mtdblock

  • The mtdblock layer creates a block device for each MTD device of the system
  • Usually named /dev/mtdblockX.
  • Allows read/write block-level access. However bad blocks are not handled, and no wear leveling is done for writes.
  • For historical reasons, JFFS2 and YAFFS2 filesystems require a block device for the mount command.
  • Do not write on mtdblock devices

Linux: ubiblock

  • Implemented by Ezequiel Garcia from Free Electrons.
  • Preferred over mtdblock if UBI is available (UBI accounts for data retention and wear leveling issues, while MTD does not)
  • The ubiblock layer creates read-only block devices on demand
  • The user specifies which static volumes (s)he would like to attach to ubiblock
  • Through the kernel command line: by passing ubi.block=,
  • Using the ubiblock utility provided by mtd-utils: ubiblock --create
  • Usually named /dev/ubiblockX_Y, where X is the UBI device id and Y is the UBI volume id

results matching ""

    No results matching ""