Loading...

Lab 114: RHEL Bootloader Basics

Inspect GRUB defaults and menu entries to confirm what the system is configured to boot, then regenerate grub.cfg safely using supported tooling. Validate installed kernels, verify the updated configuration timestamp, and confirm the system’s default boot target.

troubleshooting boot core

Scenario

A RHEL host is not booting as expected. Before changing anything, you need to inspect the current GRUB defaults, review available boot menu entries, confirm which kernels are installed, and safely regenerate /boot/grub2/grub.cfg so the configuration matches what is on disk.

Operator context

The goal is evidence-first troubleshooting. You will verify what GRUB is configured to do, regenerate configuration using supported tooling, and confirm the change by checking file timestamps and boot-related state.

Objective

  • Inspect GRUB defaults in /etc/default/grub.
  • Review GRUB menu entries from /boot/grub2/grub.cfg.
  • Identify installed kernel and initramfs artifacts in /boot.
  • Regenerate grub.cfg safely using grub2-mkconfig.
  • Verify the updated configuration via file metadata.
  • Confirm the systemd default target to understand expected boot mode.
  • Check GRUB installer version without performing writes.

Concepts

  • /etc/default/grub holds GRUB defaults that feed into the generated grub.cfg.
  • /boot/grub2/grub.cfg is generated output. Treat it as “product,” not a hand-edited source of truth.
  • When boot issues are reported, confirm what is on disk first: kernels (vmlinuz) and initramfs images must exist in /boot.
  • Regenerating configuration is safer than manual edits because it uses supported scripts and kernel discovery.
  • Boot outcome is not only GRUB. The systemd default target influences whether the system boots to multi-user or graphical mode.

Walkthrough

Step 1 : Inspect GRUB default settings.
Command
grep '^GRUB_' /etc/default/grub

This file is the primary source for GRUB defaults used when generating grub.cfg. You are confirming timeout behavior, default boot selection logic, and the kernel command line appended at boot.

GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap"
Step 2 : List available GRUB menu entries.
Command
grep '^menuentry' /boot/grub2/grub.cfg | head

Listing menuentry lines provides a fast view of what GRUB can boot. This is a practical starting point when “it boots the wrong kernel” or “rescue entry is missing” is part of the incident report.

menuentry 'Red Hat Enterprise Linux (5.14.0-427.el9.x86_64)' {
menuentry 'Red Hat Enterprise Linux (rescue)' {
Step 3 : Identify installed kernel and initramfs images.
Command
ls -1 /boot | grep -E 'vmlinuz|initramfs'

This confirms what is actually present on disk. If GRUB entries reference artifacts that do not exist, the system can fail to boot or fall back unexpectedly.

vmlinuz-5.14.0-427.el9.x86_64
initramfs-5.14.0-427.el9.x86_64.img
Step 4 : Safely regenerate GRUB configuration.
Safety note

Regenerating grub.cfg should be done with the supported command for the platform. Avoid manual edits. Write the output to the correct path for BIOS-based systems (as shown here).

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

This rebuilds GRUB’s configuration based on defaults, discovered kernels, and scripts under /etc/grub.d. You are looking for “Found linux image” lines as proof the expected kernel and initramfs were detected.

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.14.0-427.el9.x86_64
Found initrd image: /boot/initramfs-5.14.0-427.el9.x86_64.img
done
Step 5 : Verify the grub.cfg timestamp.
Command
ls -l /boot/grub2/grub.cfg

This is your quick verification that the file was regenerated and updated when you ran grub2-mkconfig. In change-controlled environments, you would also retain a copy or checksum.

-rw-------. 1 root root 41287 Aug 20 14:32 /boot/grub2/grub.cfg
Step 6 : Confirm systemd default target.
Command
systemctl get-default

If the symptom is “boots to the wrong mode,” confirm whether the system is expected to boot into a graphical or multi-user environment. This is not GRUB configuration, but it is part of the boot outcome you must validate.

graphical.target
Step 7 : Check GRUB installer version (no writes performed).
Command
grub2-install --version

This confirms which GRUB release is installed. Version awareness matters when debugging behavior across updates or validating parity across a fleet.

grub-install (GRUB) 2.06

Common breakpoints

/boot/grub2/grub.cfg does not exist

The GRUB output path differs on UEFI systems. If /boot/grub2/grub.cfg is missing, confirm the platform firmware mode and use the correct GRUB config location for that system.

grub2-mkconfig output does not show “Found linux image”

Confirm kernel and initramfs artifacts exist in /boot. If they do, verify that the GRUB scripts and defaults are present and not corrupted, then re-run the command.

The host still boots “wrong” after regenerating grub.cfg

Confirm whether “wrong” refers to kernel selection or boot mode. For boot mode, check systemctl get-default. For kernel selection, review GRUB defaults (for example, saved entry behavior) and re-check menu entries.

Cleanup checklist

This lab makes one change: regenerating grub.cfg. Your cleanup is confirming the file updated and that kernel discovery matched what is installed.

Commands
grep '^GRUB_' /etc/default/grub
grep '^menuentry' /boot/grub2/grub.cfg | head
ls -1 /boot | grep -E 'vmlinuz|initramfs'
ls -l /boot/grub2/grub.cfg
systemctl get-default
grub2-install --version
Success signal

You can show GRUB defaults, list menu entries, prove the kernel artifacts exist on disk, and demonstrate that grub.cfg was regenerated successfully by both tool output and file timestamp.

Reference

  • /etc/default/grub : GRUB defaults used when generating grub.cfg.
  • /boot/grub2/grub.cfg : Generated GRUB configuration (BIOS systems) containing menu entries and boot logic.
  • grep '^GRUB_' /etc/default/grub : Displays GRUB defaults such as timeout, default entry, and kernel command line.
  • grep '^menuentry' /boot/grub2/grub.cfg | head : Quick view of available boot menu entries.
  • ls -1 /boot | grep -E 'vmlinuz|initramfs' : Confirms installed kernel and initramfs artifacts present on disk.
  • grub2-mkconfig -o /boot/grub2/grub.cfg : Regenerates GRUB configuration using supported tooling.
    • -o : Writes output to the specified file path.
  • ls -l /boot/grub2/grub.cfg : Verifies configuration file timestamp and permissions.
  • systemctl get-default : Shows the default systemd target (expected boot mode).
  • grub2-install --version : Displays installed GRUB version without modifying system state.