Chapter Objective: Describe the stages of the RHEL boot process, control the default systemd target, use rescue and emergency mode, and recover a system that fails to boot normally.
Key commands: systemctl get-default, systemctl set-default, grub2-mkconfig, rd.break
Stages of the Boot Process
| Stage | What Happens |
|---|---|
| Firmware (UEFI/BIOS) | Hardware initializes and locates a bootable device |
| GRUB2 | The bootloader presents a menu and loads the selected kernel and initramfs |
| Kernel + initramfs | The kernel starts; a temporary initial RAM filesystem loads drivers needed to mount the real root filesystem |
| systemd (PID 1) | Takes over as the init system, bringing units up to reach the configured target |
GRUB2 Basics
# Main GRUB2 configuration is generated, not edited directly
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# On UEFI systems, the output path differs
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
# Settings that control the generated config live here — edit THIS file
sudo vi /etc/default/grub
grub.cfg is generated automatically from /etc/default/grub and the scripts in /etc/grub.d/. Edit the source files and regenerate with grub2-mkconfig instead — direct edits to grub.cfg get overwritten the next time it's regenerated.
Interrupting GRUB at Boot
Pressing a key (typically any key, or Esc/Shift depending on the system) during the brief GRUB menu window lets you edit boot parameters for a single boot without changing the permanent configuration — the basis for several recovery techniques in this chapter.
systemd Targets
Instead of traditional runlevels, RHEL boots to a systemd target — a group of units representing a system state.
| Target | Roughly Equivalent To |
|---|---|
multi-user.target | Old runlevel 3 — full multi-user, text mode, networking |
graphical.target | Old runlevel 5 — multi-user plus a graphical desktop |
rescue.target | Old single-user mode — minimal services, root shell |
emergency.target | Bare minimum — even less than rescue, no filesystems mounted beyond root |
# Show the default boot target
systemctl get-default
# Change the default target permanently
sudo systemctl set-default multi-user.target
# Switch target immediately, without rebooting
sudo systemctl isolate multi-user.target
Rescue and Emergency Mode
Both modes are reached by editing the boot entry at the GRUB menu (press e to edit, add a parameter to the line starting with linux, then Ctrl+X to boot).
# Append to the kernel line to boot into rescue mode
systemd.unit=rescue.target
# Append to boot into emergency mode instead
systemd.unit=emergency.target
Resetting a Forgotten Root Password
# At the GRUB menu, press 'e' to edit, then append to the linux line:
rd.break
# Boot with Ctrl+X. The system drops to a shell BEFORE switching root.
# Remount the real root filesystem as read-write:
mount -o remount,rw /sysroot
# Enter a chroot into the real system
chroot /sysroot
# Change the root password as normal
passwd root
# On an SELinux system, flag a full relabel on next boot (important!)
touch /.autorelabel
# Exit the chroot and reboot
exit
reboot
touch /.autorelabel ensures SELinux relabels the filesystem cleanly on the next full boot.
Troubleshooting Common Boot Failures
| Symptom | Likely Area to Check |
|---|---|
| Drops to emergency mode automatically | A bad /etc/fstab entry, or a filesystem that failed to mount |
| GRUB menu doesn't appear / boot loops before the OS | Bootloader configuration or disk/boot partition issue |
| Boots but a specific service is failing | systemctl --failed, then journalctl -u <service> |
# Review what happened during the most recent boot
journalctl -b
# Check for any failed units after boot completes
systemctl --failed
/etc/fstab early when this happens.
Key Terms for Chapter 12
- GRUB2
- The bootloader that presents a boot menu and loads the kernel and initramfs
- initramfs
- A temporary initial filesystem loaded by the kernel, containing drivers needed to mount the real root filesystem
- target
- A systemd unit grouping representing a system state, such as multi-user or graphical
- rescue.target
- A minimal boot target with local filesystems mounted, used for repairs
- emergency.target
- The most minimal boot target, with almost nothing mounted beyond root
- rd.break
- A boot parameter that drops to a shell in the initramfs, before switching to the real root filesystem
- autorelabel
- A flag (via
/.autorelabel) that triggers a full SELinux context relabel on the next boot
Review Questions
- List the four major stages of the RHEL boot process, in order.
- Why should you edit
/etc/default/grubinstead of/boot/grub2/grub.cfgdirectly? - What is the difference between
rescue.targetandemergency.target? - What command permanently changes the default boot target to
multi-user.target? - In the root password reset procedure, why is
touch /.autorelabelan important step on an SELinux-enabled system? - A system unexpectedly drops into emergency mode at every boot. What file is a very common culprit to check first?
- What command shows journal entries specifically from the most recent boot?