Creating a boot initramfs
An initial RAM filesystem or initramfs
is a compressed cpio archive. cpio is an old Unix archive format like TAR and ZIP, but it is easier to decode and so requires less code in the kernel. You need to configure your kernel with CONFIG_BLK_DEV_INITRD
to support initramfs
.
There are three different ways to create a boot ramdisk: as a standalone cpio archive, as a cpio archive embedded in the kernel image, and as a device table that the kernel build system processes as part of the build. The first option gives the most flexibility because we can mix and match kernels and ramdisks to our heart’s content. However, it means having to deal with two files instead of one, and not all bootloaders have the facility to load a separate ramdisk.
Standalone initramfs
The following sequence of instructions creates the archive, compresses it, and adds a U-Boot header to load onto the target:
$ cd ~/rootfs
$ find . | cpio -H newc -ov --owner root:root...