Creating filesystem images with device tables
We saw earlier, in the Creating a boot initramfs section, that the kernel has an option to create initramfs using a device table. Device tables are really useful because they allow a non-root user to create device nodes and to allocate arbitrary UID and GID values to any file or directory. The same concept has been applied to tools that create other filesystem image formats, as shown in this mapping from filesystem format to tool:
jffs2:mkfs.jffs2ubifs:mkfs:ubifsext2:genext2fs
We will look at jffs2 and ubifs in Chapter 9, Creating a Storage Strategy, when we look at filesystems for flash memory. The third, ext2, is a format commonly used for managed flash memory including SD cards. The example that follows uses ext2 to create a disk image that can be copied to an SD card.
To begin with, you need to install the genext2fs tool on your host. On Ubuntu, the package to install is named genext2fs:
$ sudo apt...