Linux Boot – Why Does Linux Use an Initial Ram Disk at Boot?

bootlinux

I was wondering :

What's the goal of using an initrd in the first part of the boot process and then use pivot_root to put the root on the real disk ? Why not only use what's on the disk ?

Best Answer

Why not only use what's on the disk ?

You can. You do not have to use an initrd (or an initramfs, the newer and more widespread version since kernel 2.6.13).

The reason that they are used is that distro kernels are generic and must support a wide range of hardware out of the box. Some of the drivers for different hardware, crucial to mounting a root filesystem, are possibly mutual exclusive (I'm not sure) but in any case, building all the possibilities in -- which is what you would have to do -- would make for a very massive kernel.

Thus, rather than being built into the kernel, the drivers are in separate binary modules. This is the primary payload of the initramdfs/initrd; it allows the kernel to load the appropriate drivers for the hardware so that the root filesystem can then be properly mounted.

Related Question