What is Initial Ramdisk?

Initial ramdisk is a scheme for loading a temporary filesystem into memory in the boot process of the Linux kernel. You could say it is a pseudo filesystem reflect / mirror to system. There are two scheme, initrd and initramfs. They are refer to slightly different methods and commonly used to make preparations before the real root filesystem can be mounted.

Many Linux distributions ship a single generic kernel image. They do that as they expect a wide variation of user’s hardware that might be met and thus the kernel need to be as flexible as possible. Therefore, developers need to avoid to hardcoded handling for so many special cases into the kernel body but still have to handle thus cases. The initial boot stage with a temporary root filesystem is used. This root filesystem can contain user-space halpers which do the hardware detection, module loading, and device discovery necessary to get the real root filesystem mounted.

As said before, initial ramdisk is an image of initial root filesystem (along with the kernel image), it must be stored somewhere accessible by the Linux bootloader or the boot firmware.

Prior to linux version 2.6.12, Linux use initrd scheme. The image may be a filesystem image (optionally compressed) which is made available in a special block device (/dev/ram) that is then mounted as the initial root filesystem. Once the initial root filesystem is up, the kernel executes /linuxrc as its first process. When it exits, the kernel assumes that the real root file system has been mounted and executes “/sbin/init” to begin normal user-space boot process.

In initramfs (Linux 2.6.13 onward) scheme, the image may be a cpio archive (optionally compressed). The archive is unpacked by the kernel into a special instance of a tmpfs that becomes the initial root filesystem. With this scheme, there is no requirement of intermediate filesystem or block drivers to be compiled into kernel.