Sunday, July 18, 2010

Build initrd Manually

The initial RAM disk (initrd) is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and get at the real root file system.

The initrd image contains the necessary executables and system files to support the second-stage boot of a Linux system. It contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel.

The initrd image can be created during the Linux build process. Normally, the initrd is a transient file system. Its lifetime is short, only serving as a bridge to the real root file system. In embedded systems with no mutable storage, the initrd is the permanent root file system.

To build your initrd manually, do this:
mkinitramfs -o initrd.img-2.6.34 2.6.34
Linux Kernel Support initrd
For the Linux kernel to support the initial RAM disk, the kernel must be compiled with the CONFIG_BLK_DEV_RAM and CONFIG_BLK_DEV_INITRD options.

File System Used By initrd Image
While ext2 is a common Linux file system format, there are alternatives that can reduce the size of the initrd image and the resulting mounted file systems. Examples include romfs (ROM file system), cramfs (compressed ROM file system), and squashfs (highly compressed read-only file system).

Linux Distribution by initrd
Minimax is an interesting open source project that was designed to be a Linux distribution that fits within an initrd. It's 32MB in size and uses BusyBox and uClibc for its ultra small size. Despite its small size, it's a 2.6 Linux kernel with a large array of useful tools.To build your initrd manually, do this: