Introduction differences between initramfs and initrd: ramfs vs block - less memory - dynamic resizing, no limits - rootfs always mounted for same reason pid1 unkillable. archive vs image - no filesystem driver - ramfs tiny, always loaded in 2.6. Wrapper around vfs cache. bundled vs unbundled - both available to ramfs init vs linuxrc - linuxrc sucky. - Not PID 1. - unpredictable PID, killable, zombies, etc. - strange flow control, unnecessarily complicated. - setup then return to kernel so it can mount root? - you're right there already, just do it yourself. advantages of initramfs - fundamental sequencing problem: mount / before running init. - Device enumeration complicated. (USB, anyone?) - NFS mounts require dhcp and login. - encrypt, compress, - modular filesystem driver, build into kernel. Magic format. Special. - root ext3. Initrd ext2 _not_ ext3, journal on ramdisk! Build in ext2 driver then can't get rid of it. - Binary only firmware for some devices (network cards). - Too cheap to spring for ram or flash. - Require a cross-compiler for mips to build your kernel? - initramfs has no chicken and egg problems ala nfs mounts - very simple implementation. (Small, cross-platform.) - One file. Bootloader simple to set up. - actually init - no assumptions about what you're going to do. Stay running. - root mount not "magic". Built-in root, ignorable. - moves more control to userspace - laptops, embedded systems, clusters, mainframes Build a "hello world" program in a chroot environment. Build a kernel, check out the toolchain. - Grab 2.6.17, apply miniconfig patch, use miniconfig, build, boot with hostfs. Demonstrate basic User Mode Linux. Building a "hello world" initramfs with User Mode Linux. - Build statically linked hello.c. Put in initramfs with directory method. Show it. Put in initramfs with script method. Wheee. - Build a statically linked busybox, run it as standalone shell. wget http://busybox.net/downloads/busybox-1.2.0.tar.bz2 tar xvjf busybox-1.2.0.tar.bz2 cd busybox-1.2.0 make defconfig make Now run it as standalone shell under UML with rdinit= - Transfer to new RFS (hostfs) with switch_root, by hand. Now boot a real kernel under QEMU. - Build a real kernel, run under QEMU. Package external initramfs with cpio, show initrd=. Show builtin too. Build second initrd with data and show initrd overlay on builtin base. - Cross-compile for ARM (kernel, busybox, uClibc) Get the size down: - Build dynamically linked, copy shared libraries, boot as #3. - Script to do this - Build against uClibc. Talk about klibc. - uClibc full fledged replacement for glibc. Build anything against it. klibc isn't. Doesn't even build BusyBox. - In many ways, gcc sucks. The uClibc guys recommend building gcc from source. (I run sed against the source code.) There's a wrapper too, and various ways it can break. Newer gccs break less, but can still break. (libgcc_s) Klibc also uses the wrapper. Download http://crossdev.timesys.com PATH=/opt/timesys/toolchains/i686-linux/bin:$PATH make Do real things with it: - shared libraries, directory layout, /dev, /proc, /sys - Setup quick init script. mdev -s, reproduce root= - The firmware Firmware Linux initramfs. - encfs Bonus: Extracting initramfs image from existing kernel.