Study guide
3.3 GRUB 2 Configuration & Troubleshooting (102.2)
LPIC-1 Linux Administrator — Exam 101 101-500
Track your progress as you read
Finished sections get a check mark.
1 Exam Overview & Study Strategy
1.1 LPIC-1 101-500 Exam Structure & Blueprint 1.2 Command Line & Shell Fundamentals for Exam Success 1.3 Fill-in-the-Blank Strategies & Common Traps
2 Topic 101: System Architecture
2.1 Hardware Discovery, Sysfs, Procfs & Kernel Modules (101.1) 2.2 Udev, Dbus & Device Management (101.1) 2.3 BIOS vs. UEFI & System Boot Process (101.2) 2.4 Kernel Initialization, Initramfs & System Logs (101.2) 2.5 Systemd Boot Targets & Unit Management (101.3) 2.6 SysVinit Runlevels, Telinit & System Shutdown (101.3)
3 Topic 102: Linux Installation & Boot Management
3.1 Hard Disk Layout, Partition Schemes & Swap Design (102.1) 3.2 LVM & Standard Mount Point Allocation (102.1) 3.3 GRUB 2 Configuration & Troubleshooting (102.2) 3.4 Legacy GRUB & Alternative Boot Loaders (102.2) 3.5 Managing Shared Libraries & ldconfig (102.3) 3.6 Linux as a Virtualization Guest & Cloud Instances (102.6)
4 Topic 102: Package Management Systems
4.1 Debian Low-Level Package Management with dpkg (102.4) 4.2 High-Level Debian Package Management: apt, apt-get & apt-cache (102.4) 4.3 RPM Package Management with rpm (102.5) 4.4 YUM, DNF & Zypper Package Management (102.5) 4.5 Package Repositories & Integrity Verification (102.4/102.5) 4.6 Universal Linux Packages: Snap, Flatpak & AppImage (102.4/102.5)
5 Topic 103: Command Line & Text Processing
5.1 Shell Environment, Environment Variables & Aliases (103.1) 5.2 Command History, Quoting & Expansion (103.1) 5.3 Basic Text Filters: cat, head, tail, cut, paste, nl, od (103.2) 5.4 Advanced Text Filters: sort, uniq, wc, tr, split, less & Checksums (103.2) 5.5 Stream Editing with sed (103.2) 5.6 Basic File Management: cp, mv, rm, touch, mkdir, rmdir (103.3) 5.7 Archiving and Compression: tar, gzip, bzip2, xz, cpio & dd (103.3)
6 Topic 103: Streams, Processes, Regex & Vi
6.1 Standard Streams, Redirection & File Descriptors (103.4) 6.2 Pipelines, tee & xargs (103.4) 6.3 Process Monitoring: ps, top, free, watch, pgrep, pstree & uptime (103.5) 6.4 Signals, kill, Job Control, nohup, screen & tmux (103.5) 6.5 Process Priorities: nice & renice (103.6) 6.6 Regular Expressions & grep, egrep, fgrep (103.7) 6.7 vi / vim Modes, plus nano, Emacs & EDITOR Awareness (103.8)
7 Topic 104: Devices, Partitions & Filesystems
7.1 Block Devices, fdisk & gdisk (104.1) 7.2 GNU Parted & Partition Table Management (104.1) 7.3 Creating Filesystems: mkfs, ext4, XFS, VFAT/exFAT & Btrfs (104.1) 7.4 Filesystem Integrity: fsck, e2fsck, xfs_repair, xfs_fsr & xfs_db (104.2) 7.5 Monitoring Disk Usage: df, du & tune2fs (104.2) 7.6 Managing Swap Space: mkswap, swapon & swapoff (104.1/104.2)
8 Topic 104: Mounts, Permissions, Links & FHS
8.1 Mounting and Unmounting Filesystems: mount & umount (104.3) 8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units (104.3) 8.3 Standard File Permissions: chmod, chown, chgrp & umask (104.5) 8.4 Special Permissions: SUID, SGID & Sticky Bit (104.5) 8.5 Hard Links vs. Symbolic Links: ln & Inodes (104.6) 8.6 Filesystem Hierarchy Standard (FHS) & File Location (104.7)
3.3 GRUB 2 Configuration & Troubleshooting (102.2)
Key Takeaways Explain This Topic AI
The primary GRUB 2 configuration file is /boot/grub/grub.cfg (or /boot/grub2/grub.cfg on RHEL/CentOS); it is auto-generated and must NEVER be edited directly.
System administrators customize GRUB 2 settings by editing /etc/default/grub and adding modular executable scripts to /etc/grub.d/.
Configuration changes are compiled into grub.cfg using the grub-mkconfig -o command (or update-grub on Debian/Ubuntu).
Scripts located in /etc/grub.d/ must have their execute bit set (chmod +x) to be executed by grub-mkconfig.
Emergency recovery parameters like init=/bin/bash or rd.break are appended to the linux kernel line by pressing 'e' at the interactive GRUB 2 boot menu.
Last updated: August 2026
3.3 GRUB 2 Configuration & Troubleshooting (102.2)
Quick Summary: GRUB 2 (Grand Unified Bootloader version 2) is the default bootloader for modern Linux distributions. Unlike its legacy predecessor, GRUB 2 relies on an auto-generated configuration file located at /boot/grub/grub.cfg (or /boot/grub2/grub.cfg ). Administrators control boot parameters, timeouts, and default kernels by editing /etc/default/grub and scripts in /etc/grub.d/ , compiling them with grub-mkconfig . Mastering interactive editing ( e ), the GRUB command shell ( c ), and rescue recovery commands is essential for system maintenance and LPIC-1 certification.
1. GRUB 2 Architecture and Component Hierarchy
GRUB 2 separates configuration source files from the active runtime configuration file. Direct manual edits to /boot/grub/grub.cfg will be completely overwritten during the next kernel update or configuration generation. ┌─────────────────────────┐ ┌─────────────────────────┐
- │ /etc/default/grub │ │ /etc/grub.d/ │
- │ Key-Value Global Vars │ │ 00_header, 10_linux... │
- │ (TIMEOUT, CMDLINE...) │ │ Executable Gen Scripts │
- └────────────┬────────────┘ └────────────┬────────────┘
- │ │
- └───────────────┬────────────────┘
- ▼
- [ grub-mkconfig -o ... ]
- [ (or update-grub) ]
- │
- ▼
- ┌─────────────────────────┐
- │ /boot/grub/grub.cfg │
- │ (DO NOT EDIT DIRECT!) │
- └─────────────────────────┘
- Primary Configuration File Paths
- Debian / Ubuntu / openSUSE: /boot/grub/grub.cfg
- RHEL / CentOS / Fedora / Rocky Linux (BIOS): /boot/grub2/grub.cfg
RHEL / CentOS / Fedora (UEFI): /boot/efi/EFI/redhat/grub.cfg or /boot/efi/EFI/centos/grub.cfg (or /boot/grub2/grub.cfg symlinked in modern releases)
2. Configuration Templates: /etc/default/grub
The /etc/default/grub file contains global variables that define bootloader behavior, visual themes, and kernel command-line parameters. # Sample /etc/default/grub configuration
- GRUB_TIMEOUT=5
- GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release 2>/dev/null || true)"
- GRUB_DEFAULT=saved
- GRUB_SAVEDEFAULT="true"
- GRUB_DISABLE_SUBMENU="true"
- GRUB_TERMINAL_OUTPUT="console"
- GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/sda2 quiet splash"
- GRUB_DISABLE_RECOVERY="true"
- Key Directives Reference
Directive Value Syntax Operational Effect
GRUB_DEFAULT 0 , saved , or "entry_title" Specifies which menu entry boots by default. 0 boots the first entry; saved boots the entry selected by grub-set-default or grub-reboot .
GRUB_TIMEOUT Integer (e.g., 5 , 10 , 0 , -1 ) Number of seconds the boot menu displays before booting GRUB_DEFAULT . -1 waits indefinitely; 0 boots immediately without displaying the menu.
GRUB_TIMEOUT_STYLE menu , countdown , or hidden menu displays the full list; hidden hides the menu unless Esc or Shift is pressed.
GRUB_CMDLINE_LINUX Quoted string Arguments passed to the Linux kernel for all standard boot entries (e.g., "quiet splash console=ttyS0" ).
GRUB_CMDLINE_LINUX_DEFAULT Quoted string Arguments appended only to normal (non-recovery) boot entries.
GRUB_DISABLE_RECOVERY "true" or "false" When "true" , suppresses the generation of single-user recovery mode menu entries.
GRUB_SAVEDEFAULT "true" or "false" When "true" and GRUB_DEFAULT=saved , GRUB remembers the last manually booted menu entry as the new default.
3. Modular Script Generators: /etc/grub.d/
The /etc/grub.d/ directory contains shell scripts executed in alphanumerical order by grub-mkconfig to construct grub.cfg .
00_header : Sets environmental variables, terminal displays, graphic modes, and timeout settings from /etc/default/grub .
10_linux : Scans /boot for installed Linux kernels ( vmlinuz-* ) and creates corresponding boot menu entries.
20_memtest86 : Detects standalone memory testing binaries (e.g., Memtest86+) and adds diagnostic menu entries.
30_os-prober : Executes os-prober to scan all attached storage drives for other operating systems (Windows, other Linux distributions) and generates dual-boot menu entries.
40_custom : A template script where administrators can append static, custom boot stanzas.
41_custom : Automatically sources /boot/grub/custom.cfg at boot time if it exists.
⚠️ LPIC-1 Trap: Any script in /etc/grub.d/ MUST have executable permissions ( chmod +x /etc/grub.d/* ). If a script lacks the +x bit, grub-mkconfig silently ignores it without generating an error, and its entries will not appear in grub.cfg .
- 4. Generating Configuration and Installing the Bootloader
- Compiling the GRUB 2 Configuration # Standard generic command (RHEL, Fedora, CentOS, openSUSE)
- sudo grub-mkconfig -o /boot/grub/grub.cfg
- # OR on RHEL/CentOS systems
- sudo grub2-mkconfig -o /boot/grub2/grub.cfg
- # Debian / Ubuntu wrapper command
- sudo update-grub
- Installing the Bootloader to Disk
grub-install writes the core bootloader code and stage images to the Master Boot Record (MBR) or EFI System Partition (ESP). # BIOS / MBR Installation (target the WHOLE DISK, not a partition)
- sudo grub-install /dev/sda
- # OR
- sudo grub2-install /dev/sda
- # UEFI Installation
- sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
💡 LPIC-1 Exam Fill-in-the-Blank Alert: When asked for the exact command to install GRUB 2 to the master boot record of the primary SATA drive, the command is grub-install /dev/sda (never specify partition numbers like /dev/sda1 for BIOS MBR installs).
5. Interactive Boot Menu Operations & Troubleshooting
When the system boots, the GRUB 2 visual menu presents several key interactive controls:
e (Edit): Opens the inline editor for the highlighted boot entry. Allows administrators to modify kernel boot arguments dynamically for a single boot without modifying grub.cfg .
c (Command-Line): Drops into the full interactive GRUB 2 command shell ( grub> ).
Ctrl+X or F10 : Boots the system with the edited in-memory configuration.
Esc : Aborts editing and returns to the main menu.
Critical Kernel Override Arguments for Troubleshooting
To recover a system with a forgotten root password or broken systemd service, press e at the GRUB menu, navigate to the line beginning with linux (or linux16 / linuxefi ), and append one of the following arguments: # Bypass init and spawn a direct root shell
linux /vmlinuz-5.14.0 root=/dev/sda2 ro init=/bin/bash
- # Boot into single-user / rescue target (systemd)
- linux /vmlinuz-5.14.0 root=/dev/sda2 ro systemd.unit=rescue.target
- # Emergency breakpoint in initramfs (RHEL/CentOS)
- linux /vmlinuz-5.14.0 root=/dev/sda2 ro rd.break
- 6. GRUB Rescue Mode Shell Recovery
If GRUB 2 cannot find its configuration file or secondary stage modules in /boot/grub , it drops into the minimal grub rescue> shell. # 1. List all detected storage devices and partitions
- grub rescue> ls
- (hd0) (hd0,msdos1) (hd0,msdos2)
- # 2. Browse filesystems to find the boot directory and grub modules
- grub rescue> ls (hd0,msdos1)/
- grub rescue> ls (hd0,msdos1)/boot/grub
- # 3. Set the root and prefix environment variables
- grub rescue> set root=(hd0,msdos1)
- grub rescue> set prefix=(hd0,msdos1)/boot/grub
- # 4. Load the normal execution module and launch the standard menu
- grub rescue> insmod normal
- grub rescue> normal
Once the system boots successfully into Linux, the administrator must repair the bootloader permanently by running grub-install /dev/sda followed by grub-mkconfig -o /boot/grub/grub.cfg .