The kernel command line and initramfs

Intermediate · 17 min

How the bootloader passes parameters to the kernel, how to read and change them, and how the initramfs finds and mounts the real root filesystem.

Before thisFrom firmware to bootloader: UEFI and GRUB

Sagar Kapoor · 17 min

The kernel command line and initramfs

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Sagar KapoorReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The bootloader hands the kernel a single line of text, the kernel command line. /proc/cmdline shows what the running kernel received.
  • The kernel consumes parameters it knows (root=, ro, quiet, module.option=value). Unknown ones without a dot are passed on to init, as environment variables or arguments.
  • The initramfs is a compressed cpio archive the bootloader loads next to the kernel. The kernel unpacks it into memory and runs its /init, which loads storage drivers, finds the root filesystem named by root=, mounts it, and switches to it.
  • Debian and Ubuntu servers build the initramfs with initramfs-tools (update-initramfs -u). Fedora and RHEL use dracut (dracut -f). Ubuntu desktop moved to dracut in 25.10.
  • Rebuild the initramfs after changing anything needed before the root filesystem is mounted: storage or encryption drivers, LVM or RAID, and some module options.

The kernel needs instructions

The bootloader has loaded the kernel into memory. The kernel now has to answer questions it cannot answer alone. Which disk holds the root filesystem? Should it mount it read-only first? Should it print every message or stay quiet? Should a misbehaving driver be switched off?

The answers arrive as one line of text, the kernel command line, which the bootloader passes along. In the previous lesson you saw where it comes from: GRUB_CMDLINE_LINUX on Debian, grubby --args on the Red Hat family. On a running system, cat /proc/cmdline shows exactly what the kernel received. A typical line looks like this:

BOOT_IMAGE=/vmlinuz-6.12.0-... root=UUID=3f1c... ro quiet

That example line is illustrative, written from the parameter documentation, not copied from a machine.

How parameters are read

The kernel’s parameter documentation lists hundreds of options, each tagged with the subsystem it belongs to. A few you will use:

  • root= names the root filesystem. The kernel docs say it is “usually … a block device specifier of some kind”. Use root=UUID=... rather than /dev/sda2, because device names can change between boots and UUIDs do not. The udev lesson explains why.
  • ro mounts root read-only at first, so it can be checked before being remounted read-write.
  • quiet disables most log messages during boot. Remove it when debugging a boot.
  • init= runs a different program instead of /sbin/init. This is the classic emergency trick, covered in the recovery lesson.
  • module.param=value sets an option for a module, for example usbcore.blinkenlights=1 from the docs.

The kernel docs also describe what happens to the rest: a parameter the kernel does not recognize and that contains no dot “gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init”. That is how systemd.unit=rescue.target, or a plain single, reaches PID 1, which the systemd lesson uses.

The problem initramfs solves

Here is the chicken-and-egg problem again. The root filesystem might sit on an NVMe drive, inside software RAID, on LVM, encrypted with LUKS, or on the network. Each needs a driver, and often user-space tools, before the filesystem can be read. Distribution kernels build most drivers as modules to stay small. And the modules live on the root filesystem.

The initramfs breaks the loop. It is a small archive that the bootloader loads into memory next to the kernel, containing just enough of a Linux system to find and mount the real root. The kernel documentation describes the handoff: the archive is “extracted into rootfs when the kernel boots up”, then the kernel “checks to see if rootfs contains a file ‘init’, and if so it executes it as PID 1”. That init is “responsible for bringing the system the rest of the way up, including locating and mounting the real root device”, and it then switches to the real root and runs the real init.

Think of it as a moving van that arrives before the furniture: it brings the tools needed to open the house, then leaves.

Looking inside a real one

I downloaded Alpine 3.24’s netboot initramfs from Alpine’s mirror and unpacked it on a Mac with gzip and cpio. It is a 28 MB gzip file holding an 82 MB cpio archive with 742 entries, 347 of them kernel modules (.ko files), plus BusyBox and a 30 KB shell script at /init. The script shows the textbook sequence. It reads the command line:

set -- $(cat "$ROOT"/proc/cmdline)

and defaults the next init with : "${KOPT_init:=/sbin/init}". If root= was given, it runs a helper to find the device, mounts it read-only unless told otherwise (-o "${KOPT_rootflags:-ro}"), and finally hands over:

exec switch_root $switch_root_opts $sysroot $chart_init "$KOPT_init" $KOPT_init_args

Those lines are copied from the file. I did not boot it. Debian’s and Red Hat’s initramfs images are built by different tools but follow the same plan.

Building the initramfs

Each distribution family has its own generator, and package scripts run it automatically when a kernel is installed. You run it by hand after changing something the early boot needs.

  • Debian and Ubuntu servers: initramfs-tools. sudo update-initramfs -u updates the image for the latest kernel, -k all for every installed kernel. Its man page sums up the design: “All finding of the root device happens in this early userspace.”
  • Fedora and RHEL: dracut. sudo dracut -f regenerates the image for the running kernel; without --force, dracut refuses to overwrite an existing image. The man page leaves the file location to distribution policy, which on Fedora and RHEL is /boot/initramfs-<version>.img, and --regenerate-all rebuilds every installed kernel’s image. dracut reads its own parameters from the command line, such as rd.break to stop before switching root and rd.shell to allow a shell if mounting fails.
  • Ubuntu desktop switched to dracut by default in 25.10, according to its release notes; servers kept initramfs-tools at that point.

The usual reasons to rebuild: you moved root onto LVM, RAID or LUKS, added a storage driver, or changed options for a module that loads early.

About the video

The embed is Sagar Kapoor’s “Q29. Initramfs: Understanding, Troubleshooting & Recovery”, August 2026, 17 minutes, in full. It is an RHCSA-style exercise on RHEL: it explains what the initramfs and its init program do and how the switch to the real root happens, then deliberately corrupts the image, boots into rescue mode, and rebuilds it. I judged that from the chapters and description. It covers dracut only, not initramfs-tools, and says little about the wider kernel command line, which this lesson adds. It is a small channel; English was judged from the title, description and the original English (US) audio track YouTube reports. The same creator’s video on grubby and /proc/cmdline is in deeper, along with the kernel chapter of Joe Collins’s boot walkthrough.

What was run: downloading and unpacking Alpine’s initramfs on a Mac and reading its /init. Parameter behaviour is quoted from the kernel’s admin guide and initramfs documentation, dracut.cmdline(7) and Debian’s update-initramfs(8), and the Ubuntu change from its 25.10 release notes as reported in search results, checked 2026-11-28.

Check yourself

  1. 01You added a parameter in GRUB and want to confirm the running kernel actually received it. Where do you look?

    cat /proc/cmdline. It shows the exact command line the running kernel booted with.

  2. 02Why can't the kernel just mount the root filesystem itself?

    The driver or setup needed to reach it, such as an NVMe or RAID driver, LUKS decryption or LVM, may be a module on that very filesystem or need user-space tools. The initramfs carries those pieces so they are available before the root is mounted.

  3. 03What does root=UUID=... buy you over root=/dev/sda2?

    Stability. Device names like sda can change between boots when disks are added or detected in a different order; a filesystem UUID does not.

  4. 04After moving the root filesystem onto LVM on a RHEL machine, it drops to a dracut emergency shell at boot. What is the likely fix?

    Rebuild the initramfs with dracut -f so it includes LVM support, then make sure the kernel command line points root= at the logical volume.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark