From 6b8e3545c3d46a72e0ebd0f0cc53841e26ceee25 Mon Sep 17 00:00:00 2001 From: John Ogness Date: Thu, 28 Feb 2019 16:23:38 +0106 Subject: notes: initrd.txt: add information about initrd vs initramfs There are some big differences between initrd and initramfs. This text document lists them and the advantages/disadvantages. Signed-off-by: John Ogness --- schulung_tools/notes/initrd.txt | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 schulung_tools/notes/initrd.txt diff --git a/schulung_tools/notes/initrd.txt b/schulung_tools/notes/initrd.txt new file mode 100644 index 0000000..e88b20b --- /dev/null +++ b/schulung_tools/notes/initrd.txt @@ -0,0 +1,41 @@ +# +# For both initrd variants it is assumed the root filesystem files are +# located at /home/devel/rootfs ... +# + + +# To create the archive-based initial ramdisk: + +cd /home/devel/rootfs +find . | cpio -o -H newc | gzip -9c > ../initrd.cpio.gz + + +# To create the image-based initial ramdisk: + +dd if=/dev/zero of=initrd.img bs=4M count=1 +/sbin/mkfs.ext2 initrd.img +sudo mount -o loop initrd.img /mnt +sudo cp -a /home/devel/rootfs/. /mnt/ +sudo umount /mnt +gzip -9 initrd.img + + +# +# The image-based initial ramdisk is the old way of doing things. It +# really has no advantages. But it does have disadvantages: +# +# - the size if limited by the image +# - the size is limited by the kernel configurations +# (CONFIG_BLK_DEV_RAM, CONFIG_BLK_DEV_RAM_SIZE) +# - the kernel root= parameter must be set to /dev/ram0 +# - the real root filesystem must unmount it after pivot_root +# (which means the real root filesystem has knowledge of an initrd) +# +# The archive-based initial ramdisk has the following differences/advantages: +# +# - very simple to create (no root rights required!) +# - uses exactly as much RAM as needed (grows dynamically) +# - does not require any special boot arguments +# - does not need to be "cleaned up" after switch_root +# (the real root filesystem has no knowledge that an initrd existed) +# -- cgit v1.2.3