Linux – Patching the kernel to allow booting without initrd

filesystemsinitramfsinitrdlinux-kernelroot-filesystem

The first answer of 'Why does Linux use an Initial Ram Disk at boot?' states that the initrd/initial ram filesystem is used to provide drivers to mount the real root filesystem. It also says that it is possible to patch these drivers into the kernel so an initrd or initial ram filesystem is not required, but gave no explanation of how. How can I patch the kernel (latest version) to mount an EXT4 filesystem at root without the aid of the initrd, and will this solution support UUIDs?

Best Answer

You don't need to patch anything. You just need to configure and compile the kernel by yourself. This is advanced task so it is not for begginers. The trick is to configure the kernel to support just your hardware and compile everything inside the kernel and not as a module (at least the drivers necessary for booting: disk controller, filesystem, …).

There are plenty of tutorials, how to configure and compile your kernel

So just google "kernel compile {your distro}". It is important to use correct tutorial for your distro. Distro you are using may expect some functionality available only in "distro" kernel and not in "vanilla" kernel. Correct tutorial will point you to correct sources.

You can use UUIDs in /etc/fstab but not in GRUB after removing initrd/initramfs.

For example, I'm using Gentoo and I have never used initrd/initramfs. Everytime the new kernel is available, I must configure and compile it by myself. I'm using grub with root=/dev/sdb4 kernel parameter but in fstab I'm using UUIDs.

Related Question