Skip to content

Linux Foundations / Understand the system underneath ยท Step 28 of 38

Lesson: Boot Process: BootloaderSwitch
โ† Linux Foundations

System administration

Boot Process: Bootloader

See how GRUB loads the kernel and initramfs, and how to change kernel parameters safely.

The firmware starts a bootloader. Its job is to load the Linux kernel into memory and hand over control. Most PC distributions use GRUB 2. Other choices include systemd-boot, and U-Boot on many embedded boards.

What GRUB loads

For a normal boot, GRUB needs three things:

  • the kernel image, usually named like /boot/vmlinuz-<version>
  • the initial RAM filesystem, named initrd.img-<version> or initramfs-<version>.img depending on the distribution
  • the kernel command line, a string of parameters

GRUB shows a menu where you can pick another kernel or a recovery entry. The menu may be hidden. Pressing Esc or holding Shift during the short countdown often reveals it, although this does not work on every machine.

Kernel parameters

You can read the parameters used for the current boot:

$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-6.8.0-45-generic root=/dev/mapper/vg-root ro quiet

Common ones are:

  • root= says which device holds the root filesystem
  • ro mounts it read-only at first
  • quiet hides most boot messages
  • systemd.unit=rescue.target starts a minimal repair environment on systemd systems

Editing for one boot

In the GRUB menu, highlight an entry and press e. Find the line that begins with linux, change the parameters, then press Ctrl+x or F10 to boot. This edit is temporary. Nothing is written to disk, so a mistake disappears at the next restart.

Making a permanent change

The file grub.cfg is generated, so do not edit it by hand. Change the settings in /etc/default/grub instead:

GRUB_TIMEOUT=5
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Then regenerate the configuration. The command differs between distributions. On Debian and Ubuntu:

$ sudo update-grub

On current Fedora, and on RHEL 9 and related systems:

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Older releases such as RHEL 8 use a different output path on UEFI machines. Some of these systems also keep each menu entry in /boot/loader/entries, where regenerating alone may not change kernel parameters, and the grubby tool is used instead. Check your distribution's documentation first.

The full option list is in the GNU GRUB manual.

Try it

Without changing anything, run cat /proc/cmdline and ls /boot. Match the kernel named in the command line to a file in the listing. Then read /etc/default/grub and find your timeout value. Practise editing only on a virtual machine with a snapshot.

Check your understanding

Boot Process: Bootloader

All 5 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.