RED HAT ENTERPRISE LINUX

Boot Management

Controlling Services and Troubleshooting Boot Problems

College-Level Course Module | RHEL System Administration

Learning Objectives

1
Understand the RHEL boot process

From firmware initialization through systemd to login

2
Manage systemd targets

Control system states and which services start at boot

3
Configure GRUB bootloader

Modify boot parameters and select different kernels

4
Troubleshoot boot problems

Use rescue mode, emergency mode, and reset root password

The Boot Process

1
Firmware (BIOS/UEFI) - Hardware initialization, POST, find boot device
2
GRUB2 Bootloader - Display menu, load kernel and initramfs into memory
3
Kernel Initialization - Decompress, initialize hardware, mount initramfs as temporary root
4
initramfs - Load drivers, find real root filesystem, pivot_root to real root
5
systemd (PID 1) - Start services, reach default target, present login
Key insight: Each stage hands off to the next. Problems at any stage prevent reaching later stages. Identify which stage fails to know where to troubleshoot.

Firmware and GRUB

BIOS vs UEFI

  • BIOS: Legacy, MBR partitions, /boot on disk
  • UEFI: Modern, GPT partitions, EFI System Partition
  • UEFI supports Secure Boot
  • RHEL supports both

GRUB2 Bootloader

  • Config: /boot/grub2/grub.cfg
  • Defaults: /etc/default/grub
  • Regenerate: grub2-mkconfig
  • Supports multiple kernels
# Check if system uses UEFI or BIOS
[root@server ~]# [ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS"
UEFI

# View GRUB configuration
[root@server ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root"

# List available kernels
[root@server ~]# grubby --info=ALL | grep ^kernel

Kernel and initramfs

The kernel is the core of Linux. The initramfs (initial RAM filesystem) is a temporary root filesystem that contains drivers and tools needed to mount the real root.

# View installed kernels
[root@server ~]# rpm -qa kernel
kernel-5.14.0-362.8.1.el9_3.x86_64
kernel-5.14.0-362.13.1.el9_3.x86_64

# Current running kernel
[root@server ~]# uname -r
5.14.0-362.13.1.el9_3.x86_64

# Kernel and initramfs files in /boot
[root@server ~]# ls /boot/vmlinuz* /boot/initramfs*
/boot/vmlinuz-5.14.0-362.8.1.el9_3.x86_64
/boot/vmlinuz-5.14.0-362.13.1.el9_3.x86_64
/boot/initramfs-5.14.0-362.8.1.el9_3.x86_64.img
/boot/initramfs-5.14.0-362.13.1.el9_3.x86_64.img

# Rebuild initramfs (if drivers or config changed)
[root@server ~]# dracut -f /boot/initramfs-$(uname -r).img $(uname -r)

# View initramfs contents
[root@server ~]# lsinitrd /boot/initramfs-$(uname -r).img | head
Why initramfs? The kernel can't include drivers for every possible storage setup. initramfs provides drivers for your specific hardware (LVM, RAID, encryption) to mount the real root.

systemd Targets

Targets are systemd units that define system states. They group services and other units that should be active together. Targets replaced traditional SysV runlevels.

TargetPurposeOld Runlevel
poweroff.targetSystem shutdown0
rescue.targetSingle-user rescue mode1
multi-user.targetMulti-user text mode (servers)3
graphical.targetMulti-user with GUI (desktops)5
reboot.targetSystem reboot6
emergency.targetMinimal emergency shell-
# View current target
[root@server ~]# systemctl get-default
graphical.target

# View active target
[root@server ~]# systemctl list-units --type=target --state=active

Target Details

multi-user.target

Full system, multiple users, network active, all services. No GUI. Standard for servers.

graphical.target

Everything in multi-user plus display manager and desktop. Standard for workstations.

rescue.target

Single-user, root filesystem mounted, basic services only. Root password required. For maintenance.

emergency.target

Minimal shell, root filesystem read-only, no services. For when rescue fails. Requires root password.

# View what services are in a target
[root@server ~]# systemctl list-dependencies graphical.target | head -15

# Targets are hierarchical - graphical includes multi-user
[root@server ~]# systemctl list-dependencies graphical.target | grep target
graphical.target
├─multi-user.target
│ ├─basic.target
│ │ ├─paths.target
│ │ ├─sockets.target
│ │ └─sysinit.target
Target hierarchy: graphical.target depends on multi-user.target, which depends on basic.target, which depends on sysinit.target. Each adds more functionality.

Changing Default Target

# View current default target
[root@server ~]# systemctl get-default
graphical.target

# Change default to multi-user (text mode)
[root@server ~]# systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.

# Verify the change
[root@server ~]# systemctl get-default
multi-user.target

# Change default to graphical (GUI)
[root@server ~]# systemctl set-default graphical.target

# The default target is just a symlink
[root@server ~]# ls -l /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 40 Jan 20 10:00 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
Takes effect on next boot: Changing the default target doesn't affect the running system. The new target is used on the next boot.

Switching Targets at Runtime

# Switch to a different target immediately (isolate)
[root@server ~]# systemctl isolate multi-user.target
# GUI stops, drops to text console

# Switch to graphical
[root@server ~]# systemctl isolate graphical.target
# Display manager starts, GUI appears

# Enter rescue mode (single-user)
[root@server ~]# systemctl isolate rescue.target
# Services stop, single-user shell

# Reboot the system
[root@server ~]# systemctl isolate reboot.target
# Or simply:
[root@server ~]# systemctl reboot

# Shutdown the system
[root@server ~]# systemctl poweroff
isolate is disruptive! Switching targets stops services not needed by the new target. Users may be disconnected. Use carefully on production systems.

Modifying GRUB at Boot

GNU GRUB version 2.06
Red Hat Enterprise Linux (5.14.0-362.13.1.el9_3.x86_64) 9.3
Red Hat Enterprise Linux (5.14.0-362.8.1.el9_3.x86_64) 9.3
Red Hat Enterprise Linux (0-rescue-abc123) 9.3

Use ↑ and ↓ to change selection.
Press 'e' to edit commands, 'c' for command-line.
At GRUB menu:
↑/↓ - Select kernel
Enter - Boot selected entry
e - Edit boot parameters (temporary)
c - GRUB command line

Editing Boot Parameters

# After pressing 'e' at GRUB menu, you see the boot entry:
setparams 'Red Hat Enterprise Linux (5.14.0-362.13.1.el9_3.x86_64) 9.3'
        
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod xfs
        ...
        linux ($root)/vmlinuz-5.14.0-362.13.1.el9_3.x86_64 root=/dev/mapper/rhel-root 
              ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap 
              rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap
        initrd ($root)/initramfs-5.14.0-362.13.1.el9_3.x86_64.img

# Find the line starting with 'linux' and add parameters at the end:

# Boot to rescue mode:
linux ... rd.lvm.lv=rhel/swap systemd.unit=rescue.target

# Boot to emergency mode:
linux ... rd.lvm.lv=rhel/swap systemd.unit=emergency.target

# After editing, press Ctrl+x to boot with changes
Ctrl+x boots with your changes. Ctrl+c discards changes. Esc returns to menu.

Rescue Mode

Rescue mode boots to a single-user shell with root filesystem mounted read-write and basic services running. Use for maintenance and repairs.

# Method 1: From GRUB, edit boot entry, add to linux line:
systemd.unit=rescue.target

# Method 2: From running system
[root@server ~]# systemctl isolate rescue.target

# What you see in rescue mode:
Welcome to rescue mode! Type "systemctl default" or "systemctl reboot"...
Give root password for maintenance
(or press Control-D to continue):

# After entering root password:
[root@server ~]# # Full root shell, root filesystem mounted rw

# Do your maintenance work, then:
[root@server ~]# systemctl default     # Continue to normal boot
# Or:
[root@server ~]# systemctl reboot      # Reboot the system
Requires root password! Rescue mode prompts for the root password. If you've forgotten it, use emergency mode with rd.break instead.

Emergency Mode

Emergency mode is more minimal than rescue. Root filesystem is mounted read-only, almost no services run. Use when rescue mode itself fails.

# From GRUB, add to linux line:
systemd.unit=emergency.target

# What you see:
Welcome to emergency mode! After logging in, type "journalctl -xb"...
Give root password for maintenance
(or press Control-D to continue):

# After entering root password:
[root@server ~]# mount
/dev/mapper/rhel-root on / type xfs (ro,relatime,...)  # Read-only!

# Remount root filesystem read-write to make changes
[root@server ~]# mount -o remount,rw /

# Now you can edit files
[root@server ~]# vi /etc/fstab

# When done:
[root@server ~]# systemctl reboot
Emergency vs Rescue: Use rescue first. If rescue fails (bad service configuration, etc.), emergency is more minimal and might work.

Breaking into initramfs

rd.break interrupts boot in initramfs before the real root is mounted. This bypasses systemd and the root password, allowing password reset.

# From GRUB, add to end of linux line:
rd.break

# Boot with Ctrl+x - you get an initramfs shell:
Entering emergency mode. Exit the shell to continue.
Type "journalctl" to view system logs.
You might want to save "/run/initramfs/rdsosreport.txt"

switch_root:/#

# The real root filesystem is mounted at /sysroot, read-only
switch_root:/# mount | grep sysroot
/dev/mapper/rhel-root on /sysroot type xfs (ro,relatime,...)

# Remount read-write
switch_root:/# mount -o remount,rw /sysroot

# Change root into the real root filesystem
switch_root:/# chroot /sysroot
Security implication: rd.break bypasses authentication! Physical access = root access. Protect servers physically and with GRUB passwords.

Resetting Root Password

# 1. At GRUB, edit boot entry (press 'e')
# 2. Add rd.break to end of linux line
# 3. Boot with Ctrl+x

# 4. Remount /sysroot read-write
switch_root:/# mount -o remount,rw /sysroot

# 5. Change root into real filesystem
switch_root:/# chroot /sysroot

# 6. Reset the password
sh-5.1# passwd root
Changing password for user root.
New password: 
Retype new password:
passwd: all authentication tokens updated successfully.

# 7. CRITICAL: Fix SELinux context (or system won't boot!)
sh-5.1# touch /.autorelabel

# 8. Exit and reboot
sh-5.1# exit
switch_root:/# exit
# System reboots, SELinux relabels (may take several minutes)
Don't forget /.autorelabel! The password file gets wrong SELinux context. Without relabeling, you still won't be able to log in!

Troubleshooting Boot Failures

SymptomLikely CauseSolution
No video outputHardware, firmwareCheck cables, BIOS settings
No GRUB menuBootloader problemBoot rescue media, reinstall GRUB
Kernel panicKernel/driver issueBoot older kernel from GRUB
Drops to initramfs shellCan't find root FSCheck root=, LVM, encryption
Stuck at "Started..." messageService hangingBoot with emergency.target
Can't login, password correctSELinux, PAMBoot rescue, check /var/log, relabel
Filesystem errorsCorrupted FSBoot rescue, run fsck
Can't mount filesystemBad /etc/fstabBoot emergency, fix fstab
# Check boot logs after successful boot
[root@server ~]# journalctl -b                  # This boot
[root@server ~]# journalctl -b -1               # Previous boot
[root@server ~]# journalctl -b -p err           # Errors only
[root@server ~]# systemctl --failed             # Failed services

Recovering from fstab Errors

A bad /etc/fstab entry can prevent normal boot. The system may drop to emergency mode or fail to mount filesystems.

# System won't boot due to fstab error - you see:
Welcome to emergency mode! ...
Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.
Press Enter to continue.

# Solution: Boot with rd.break, fix fstab

# 1. Edit GRUB entry, add rd.break, boot with Ctrl+x
# 2. Remount /sysroot read-write
switch_root:/# mount -o remount,rw /sysroot

# 3. Edit fstab
switch_root:/# vi /sysroot/etc/fstab
# Fix or comment out the bad entry

# 4. Exit to continue boot
switch_root:/# exit

# Alternative: Add this to kernel line to ignore fstab errors:
systemd.unit=emergency.target
# Then remount root rw and fix fstab

Persistent GRUB Changes

# Edit GRUB defaults
[root@server ~]# vi /etc/default/grub

# Common settings:
GRUB_TIMEOUT=5                    # Seconds before auto-boot
GRUB_DEFAULT=saved                # Remember last selection
GRUB_DISABLE_SUBMENU=true         # Flat menu, no submenus
GRUB_CMDLINE_LINUX="..."          # Kernel parameters for all boots

# After editing, regenerate grub.cfg:
# For BIOS systems:
[root@server ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

# For UEFI systems:
[root@server ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

# Set default kernel to boot
[root@server ~]# grubby --default-kernel
/boot/vmlinuz-5.14.0-362.13.1.el9_3.x86_64

[root@server ~]# grubby --set-default /boot/vmlinuz-5.14.0-362.8.1.el9_3.x86_64
Never edit grub.cfg directly! It's regenerated by grub2-mkconfig. Edit /etc/default/grub instead.

Boot Diagnostics

# View boot messages from current boot
[root@server ~]# journalctl -b

# View boot messages from previous boot
[root@server ~]# journalctl -b -1

# Show only errors and worse
[root@server ~]# journalctl -b -p err

# View kernel messages (dmesg equivalent)
[root@server ~]# journalctl -k

# Follow boot in real-time (on another console)
[root@server ~]# journalctl -f

# Check for failed services
[root@server ~]# systemctl --failed
  UNIT                    LOAD   ACTIVE SUB    DESCRIPTION
● httpd.service           loaded failed failed Apache HTTP Server

# Analyze boot time
[root@server ~]# systemd-analyze
Startup finished in 1.512s (kernel) + 2.313s (initrd) + 8.765s (userspace) = 12.590s

[root@server ~]# systemd-analyze blame | head -5

Best Practices

✓ Do

  • Keep multiple kernel versions installed
  • Test fstab changes with mount -a
  • Know how to access GRUB and edit entries
  • Practice password reset procedure
  • Document custom boot parameters
  • Use journalctl to review boot logs
  • Set appropriate default target
  • Create /.autorelabel after SELinux changes

✗ Don't

  • Edit grub.cfg directly
  • Remove all old kernels
  • Forget SELinux relabeling after password reset
  • Reboot without testing fstab changes
  • Ignore failed services after boot
  • Leave GRUB timeout at 0 on servers
  • Skip documentation of boot changes
  • Panic when boot fails - use systematic troubleshooting
RHCSA tip: Practice boot recovery until it's automatic. The exam will test password reset, rescue mode, and fstab recovery.

Key Takeaways

1

Boot Process: Firmware → GRUB → Kernel → initramfs → systemd. Know each stage for troubleshooting.

2

Targets: multi-user.target (servers), graphical.target (desktops). Use systemctl set-default and isolate.

3

GRUB: Press 'e' to edit boot parameters. Add systemd.unit=rescue.target or rd.break for recovery.

4

Recovery: rescue.target for maintenance, emergency.target for minimal access, rd.break for password reset.

LAB EXERCISES

  • Change the default target to multi-user.target and reboot
  • Use systemctl isolate to switch between targets
  • Edit GRUB to boot into rescue.target
  • Practice the complete root password reset procedure
  • Intentionally break /etc/fstab and recover using rd.break
  • Analyze boot performance with systemd-analyze

Next: Managing Network Security with Firewall