Solving the Chicken-and-Egg Problem
Here is the dilemma: the kernel needs to mount your root filesystem (which might be on an NVMe SSD, a software RAID array, an encrypted LVM volume, or a network share). To do that, it needs the right device driver. But those drivers are stored as modules (.ko files) on the root filesystem — the very filesystem it cannot yet access.
This is a genuine circular dependency. The solution is elegant: the initramfs.
What is initramfs?
initramfs (Initial RAM Filesystem) is a compressed cpio archive that GRUB loads into RAM alongside the kernel. The kernel mounts this archive as a temporary root filesystem entirely in memory — no disk access required. It contains:
- A minimal set of device drivers (storage controllers, filesystem drivers, crypto modules for LUKS encryption, etc.)
- Essential tools:
mount,lvm,mdadm,cryptsetup - An
initscript (usually/init) that orchestrates the pivot
The Pivot Process
The initramfs /init script runs and performs the following:
- Loads the necessary kernel modules to access the real storage device.
- Assembles any software RAID arrays (
mdadm --assemble). - Activates LVM volume groups (
lvm vgchange -ay). - Decrypts LUKS-encrypted volumes if needed (prompting for a passphrase).
- Mounts the real root filesystem at a temporary mount point.
- Calls
switch_root(orpivot_root) to replace the in-memory initramfs with the real root filesystem. - Executes
/sbin/initon the real filesystem — handing control to PID 1.
The initramfs (found at /boot/initrd.img-<kernel-version>) is a compressed cpio archive that can be extracted and browsed, revealing a small filesystem tree — bin, lib, sbin, scripts, and so on. The init file at the root is the script that runs first. The lib/modules/ directory contains the kernel modules bundled into the initramfs.
When initramfs Goes Wrong
If the initramfs cannot find or mount the real root filesystem, you will see a message to the effect of "Gave up waiting for root file system device," followed by an alert that the expected UUID does not exist and "Dropping to a shell!" This drops you into a minimal busybox shell inside the initramfs environment. Common causes: a missing storage driver, a corrupted filesystem, a wrong UUID in GRUB's kernel parameters, or a failed RAID/LVM assembly.