= initramfs = The initramfs is a complete set of directories that you would find on a normal root filesystem embedded into the Linux kernel. It is bundled into a single cpio archive and compressed with one of several compression algorithms. At boot time, the boot loader loads the kernel and the initramfs image into memory and starts the kerne. If a kernel has been built to include an initramfs it mounts that instead and ignores the 'root=' kernel parameter. Using a small root filesystem via initramfs is a great way to do Linux kernel development or work with a system that does not yet have any via-able storage available. See [wiki:buildroot buildroot] for an example of using a small ~1.5MiB buildroot rootfs attached to a kernel. To build a kernel with an initramfs configure the following kernel items: * CONFIG_INITRAMFS_SOURCE="/path/to/rootfs.cpio" * CONFIG_INITRAMFS_COMPRESSION_GZIP=y (optional) - or some other compression algorithm * CONFIG_DEVTMPFS=y (optional) - to get devtmpfs support and provide a dynamic /dev This will build a kernel that runs {{{/init}}}, {{{/sbin/init}}}, or {{{/bin/sh}}} (searched in that order) as PID1 from the initramfs (if it exists). If you want to run a different executable as PID1 you can use the {{{init=}}} kernel parameter. == external initramfs == This is a ramdisk image (cpio, or compressed cpio if you have enabled ramdisk compression in your kernel) that you pass to the kernel when booting. If doing this with U-Boot its the 2nd (middle) arg to bootm/booti/bootz. Note that {{{bootm}}} expects a uImage and uramdisk which have U-Boot wrappers (created with the {{{mkimage}}} tool from the {{{u-boot-tools}}} package) around the images. U-Boot must have CONFIG_LEGACY_IMAGE_FORMAT enabled for this. Note that arm64 does not support compressed kernel Images so you must use booti for arm64 (or bootm with a FIT image). Note that {{{booti}}} requires passing the size of the ramdisk by specifying : hello.c #include #include int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } EOF ${CROSS_COMPILE}gcc -static hello.c -o hello cat << EOF > initramfs dir /dev 755 0 0 nod /dev/console 644 0 0 c 5 1 nod /dev/loop0 644 0 0 b 7 0 dir /bin 755 1000 1000 dir /proc 755 0 0 dir /sys 755 0 0 dir /mnt 755 0 0 file /init hello 755 0 0 EOF }}} kernel args: * CONFIG_INITRAMFS_SOURCE="initramfs" * CONFIG_INITRAMFS_ROOT_UID=0 * CONFIG_INITRAMFS_ROOT_GID=0 * CONFIG_INITRAMFS_COMPRESSION_GZIP=y * CONFIG_INITRAMFS_COMPRESSION=".gz" For a more complete root filesystem take a look at [wiki:buildroot buildroot]