Skip to content
linux boot-process

initramfs

initramfs initrd boot-process linux kernel
Plain English

The initramfs is a tiny starter kit the computer loads during startup. The kernel needs to reach the main disk, but the drivers for that disk might live on the disk itself. The initramfs solves that chicken-and-egg problem by bringing the needed drivers along in memory, mounting the real disk, and then getting out of the way.

Technical Definition

An initramfs (initial RAM filesystem) is a compressed cpio archive loaded by the bootloader alongside the kernel. The kernel unpacks it into a tmpfs and runs its /init.

What it contains:

  • Storage and filesystem drivers (NVMe, SATA, ext4, LVM, RAID, encryption)
  • Tools such as cryptsetup for unlocking encrypted disks
  • Scripts that find the root device from root=UUID=... on the kernel command line
  • A minimal shell (BusyBox on Ubuntu) for when things fail

Boot sequence: bootloader loads vmlinuz and initrd.img, the kernel runs /init from the initramfs, it mounts the real root at /root, then switch_root hands over to /sbin/init (systemd).

On Ubuntu: files live at /boot/initrd.img-<version>, built by initramfs-tools. Kernel package installs rebuild it automatically. Rebuild by hand after changing /etc/crypttab, storage drivers, or hooks.

The (initramfs) prompt: if the root device cannot be found or fails a check, you land in a BusyBox shell. Common causes are a wrong UUID, a missing driver, or a filesystem that needs fsck.

The older term initrd (initial RAM disk) is still used in file names.

Source: initramfs-tools(7) Ubuntu manual page

Inspecting and rebuilding the initramfs

# Images on disk, one per kernel
$ ls -lh /boot/initrd.img-*
-rw-r--r-- 1 root root 68M Nov  1 09:12 /boot/initrd.img-7.0.0-15-generic

# What is inside
$ lsinitramfs /boot/initrd.img-$(uname -r) | grep -E "nvme|ext4" | head

# Rebuild for the running kernel
$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-7.0.0-15-generic

# At an (initramfs) prompt after a dirty shutdown
(initramfs) fsck -y /dev/sda2
(initramfs) exit
In the Wild

You rarely think about the initramfs until boot stops at an (initramfs) prompt. When it does, read the message right above it; it usually names the device it could not find or the check that failed. Running fsck on the root partition and typing exit fixes the common dirty-shutdown case. A full /boot can also leave a half-written initramfs after a kernel update, so watch /boot free space on systems that have one.