About Initramfs

1. What is initramfs?

It is ramfs that serves as an initial rootfs. It contains a complete set of directories that you would find on a normal root filesystem. It is bundled into a single cpio archive and (optionally) further compressed by one of the common compression algorithms like gzip or xz.

2. What is it used for?

Quoted from Ubuntu Wiki :

It is used for mounting the real rootfs which has all your data.

Quoted from BLFS :

The only purpose of an initramfs is to mount the root filesystem.

3. Why do we need it?

Quoted from Ubuntu Wiki :

Some system configurations need a user space utility to provoke the kernel to configure the devices appropriately. Eg: cryptdevices : they need to have a password from the user. This password requesting utility being a user space utility, could pose a chicken and egg problem i.e your rootfs contains the user space utilities, but the rootfs cannot come up till the user space utilities are available. In such cases, the initramfs plays a mediator in between giving a temporary rootfs which has bears the user space utilities needed for mounting the real rootfs.

Quoted from kernel’s doc for initrd , an older tool that shares a similar functionality with initramfs:

initrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.

Additional sources


About
"Universal Reference" and Reference Collapsing