Linux › Section F · How user space starts › Topic F.6

The initial RAM filesystem

To mount its root filesystem, the kernel may need drivers that live on that very filesystem. The initial RAM filesystem breaks the deadlock with a small, temporary user space that runs before the real one.

A chicken-and-egg problem

Once running, the Linux kernel does not use the firmware to read disks; it needs its own driver for the storage hardware. There are far too many storage controllers for a distribution to build every driver into its kernel, so most are shipped as loadable modules, which are ordinary files under /lib/modules. But files can only be read from a mounted filesystem, and the kernel is trying to mount the root filesystem in the first place. The problem grows when the root sits on software RAID, a logical volume, an encrypted LUKS volume or a network share, or is named by UUID: each needs user-space tools as well as drivers before the root can be found.

The solution: a filesystem in memory

The fix is to bundle the needed modules and a few utilities into an archive in cpio format, usually compressed. The boot loader loads this file into memory alongside the kernel; in GRUB it is the file named on the initrd line of a menu entry, as "Boot loaders and GRUB" showed. On start, the kernel unpacks the archive into rootfs, a temporary in-memory filesystem, and runs the program /init from it as PID 1. That program is a miniature user space whose only purpose is to find, prepare and mount the real root filesystem, then hand over to the real init. The archive is called the initial RAM filesystem, or initramfs.

What happens inside the initramfs

The details vary, but the steps are similar everywhere. 1. udev, or a script, loads the driver modules the hardware needs. 2. RAID arrays and logical volumes are assembled, and the user is asked for a passphrase if the root is encrypted. 3. The root device named by the root= kernel parameter, often given as root=UUID=..., is located and mounted; dracut mounts it at /sysroot. 4. A tool such as switch_root moves /proc, /dev, /sys and /run onto the new root, deletes the initramfs contents to free memory, makes the new root /, and runs the real init. On systemd distributions using dracut, the initramfs contains a cut-down systemd that performs these steps as units.

initrd and initramfs

The names are often mixed up. The older mechanism, the initial RAM disk or initrd, was a disk image holding a real filesystem that the kernel mounted from a RAM disk. The modern initramfs is a cpio archive unpacked straight into rootfs, which is simpler and needs no filesystem driver. Nearly every current system uses the cpio form, yet the word initrd survives in file names and in GRUB's initrd command. An initramfs can even be linked into the kernel image when it is built. Equally, a kernel with every driver it needs built in, and a plainly named root= device, can boot with no initramfs at all, though generic distribution kernels almost always rely on one.

Tools and files by distribution

You rarely build an initramfs by hand; a generator does it, and the package manager runs it whenever a kernel is installed. Fedora and Red Hat Enterprise Linux use dracut, writing /boot/initramfs-VERSION.img, where VERSION is the kernel release that uname -r prints; lsinitrd lists the contents. Debian uses initramfs-tools, writing /boot/initrd.img-VERSION; lsinitramfs lists it, unmkinitramfs unpacks it, and update-initramfs rebuilds it. Ubuntu Desktop switched its default to dracut from release 25.10 in 2025, while Ubuntu Server kept initramfs-tools. Arch Linux uses mkinitcpio. Whatever the tool, it copies in only the modules and programs this machine needs to reach its root filesystem.

Worked example: looking inside

On a Debian laptop whose root filesystem is on an NVMe drive, check that the NVMe driver is in the initramfs. 1. Run uname -r to get the running kernel's release. 2. Run lsinitramfs /boot/initrd.img-$(uname -r) | grep nvme. The shell replaces $(uname -r) with the release, so the right file is read. 3. Matching lines under lib/modules or usr/lib/modules show that nvme driver modules are included; the names may end in .ko or a compressed form such as .ko.xz or .ko.zst. 4. On Fedora the equivalent is lsinitrd | grep nvme, which reads the image for the running kernel by default. 5. Check: if nothing matched for a device the root needs, the next boot would fail to find the root.

Worked example: rebuilding after a change

A server's root filesystem is moving to a controller whose driver, here called examplectl, is not loaded automatically. 1. On Debian, add a line examplectl to /etc/initramfs-tools/modules, then run sudo update-initramfs -u, which rebuilds the image for the newest installed kernel (add -k all for every kernel). 2. On Fedora, create /etc/dracut.conf.d/examplectl.conf containing add_drivers+=" examplectl ", then run sudo dracut -f, which overwrites the image for the running kernel. 3. Before rebooting, confirm the driver is present with lsinitramfs or lsinitrd. 4. Keep an older kernel and its initramfs in the boot menu as a fallback. 5. Check: the change is permanent, because the generator reads these files on every future rebuild.

When the initramfs cannot find the root

If the real root never appears, the initramfs stops and drops you into a small shell instead of panicking. Debian's initramfs-tools shows an (initramfs) prompt running BusyBox; dracut opens an emergency shell and saves a report in /run/initramfs/rdsosreport.txt. The usual cause is a root= value naming a UUID that no longer exists, after a disk was replaced or reformatted, or a missing driver. From the shell, blkid lists the filesystems and UUIDs that are present, which you can compare with the kernel command line. You can also stop deliberately: rd.break on dracut systems or break=mount with initramfs-tools. "Emergency booting and single-user mode" builds on this.

Common mistakes to avoid

First, thinking the initramfs is the real root filesystem; it is temporary and is deleted at the switch to the real root. Second, adding a module to the configuration and forgetting to regenerate the image, so the boot is unchanged. Third, rebuilding the image for the wrong kernel version; check uname -r and the file name. Fourth, editing GRUB's configuration file to experiment with the initrd line, when a one-off edit from the boot menu is safer. Fifth, removing every older kernel, leaving no fallback if a new initramfs is broken. Sixth, confusing the old initrd disk image with the modern cpio initramfs just because both are called initrd.

Key takeaways

The kernel needs drivers, and often RAID, LVM or decryption tools, before it can mount the root filesystem, but those live on that filesystem. The initramfs is a compressed cpio archive, loaded by the boot loader, that the kernel unpacks into rootfs and runs as /init. It loads modules, prepares devices, mounts the root named by root=, then switch_root frees its memory and starts the real init. The term initrd survives from the older RAM-disk image. dracut (Fedora, RHEL, and Ubuntu Desktop since 25.10) and initramfs-tools (Debian, Ubuntu Server) build images; lsinitrd and lsinitramfs list them. Regenerate with dracut -f or update-initramfs -u after changes.

Flashcards

Flashcard

initramfs

A compressed cpio archive that provides an early, temporary user space

Finds and mounts the real root.

Test your understanding

Question 1 of 5

Why do generic distribution kernels need an initramfs?

Question 2 of 5

What does the kernel do with the initramfs after the boot loader has loaded it into memory?

Question 3 of 5

On a Debian server you added a driver to /etc/initramfs-tools/modules. What must you run before rebooting?

Question 4 of 5

After a disk replacement, boot stops at an (initramfs) prompt. What is the most likely cause to check first?

Question 5 of 5

Which statement about initrd and initramfs is correct?

← Previous topicNext topic →