16.3 Modify the System Bootloader
Key Takeaways
- RHEL uses GRUB2; prefer grubby for kernel argument and default-kernel changes, and understand /etc/default/grub plus grub2-mkconfig for regenerating grub.cfg.
- Persistent kernel parameters belong in bootloader config (grubby --update-kernel=ALL --args=… or GRUB_CMDLINE_LINUX in /etc/default/grub then grub2-mkconfig)—not only a one-boot GRUB edit.
- Know where grub.cfg lives (BIOS vs UEFI paths), how to list kernels with grubby --info=ALL, and how to set a default kernel index or path.
- After modifying bootloader config, reboot to prove the kernel command line (cat /proc/cmdline) matches the requirement.
- Coordinate with recovery skills (Ch8): one-boot edits help repair; deploy tasks need lasting bootloader changes.
16.3 Modify the System Bootloader
Quick Answer: List kernels with
grubby --info=ALL. Add persistent kernel args withsudo grubby --update-kernel=ALL --args="quiet foo=bar"(and--remove-args=to drop). Set default kernel withgrubby --set-default. Alternatively edit/etc/default/grub(GRUB_CMDLINE_LINUX) and rungrub2-mkconfig -o …/grub.cfg. Prove after reboot withcat /proc/cmdline.
Why bootloader modification is a deploy skill
Operate chapters taught booting, targets, and interrupting GRUB once for recovery. This objective is modify the system bootloader so changes stick:
- Add or remove kernel command-line parameters (e.g.
console=,systemd.unit=, vendor-required args, removingrhgb/quietfor noisier boot). - Change which kernel is default after installs/updates.
- Ensure configuration is correct on BIOS or UEFI layout used by the VM.
Typical wording: “Persistently configure the bootloader so the kernel boots with parameter X,” or “Set the default boot kernel to ….”
GRUB2 on RHEL: mental model
| Piece | Role |
|---|---|
| Firmware (BIOS/UEFI) | Loads GRUB |
GRUB menu / grub.cfg | Entries for kernels/initramfs |
| Kernel cmdline | Parameters passed to the kernel/systemd |
/etc/default/grub | Human-edited defaults used when regenerating config |
grubby | Red Hat-friendly tool to edit kernel entries/args |
| BLS / boot entries | UEFI boot variables (related, not always the exam focus) |
Generated config paths (know both):
| Firmware style | Common grub.cfg path |
|---|---|
| BIOS (legacy) | /boot/grub2/grub.cfg |
| UEFI | /boot/efi/EFI/redhat/grub.cfg |
# Discover what this system uses
ls /sys/firmware/efi 2>/dev/null && echo UEFI || echo BIOS-or-no-efi-sysfs
ls -l /boot/grub2/grub.cfg /boot/efi/EFI/redhat/grub.cfg 2>/dev/null
Never hand-edit grub.cfg as your first choice—it is generated and package updates may overwrite careless edits. Prefer grubby or /etc/default/grub + grub2-mkconfig.
grubby: preferred RHEL interface
Inventory
sudo grubby --info=ALL
sudo grubby --default-kernel
sudo grubby --default-index
sudo grubby --info=$(sudo grubby --default-kernel)
uname -r
cat /proc/cmdline
Each boot entry has an index, kernel path, args, initrd, etc.
Add or remove kernel arguments (persistent)
# Add args to ALL installed kernels (common exam pattern)
sudo grubby --update-kernel=ALL --args="console=ttyS0,115200"
# Add to the running/default kernel only
sudo grubby --update-kernel=DEFAULT --args="systemd.unit=multi-user.target"
# Add to one specific kernel file
sudo grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="foo=bar"
# Remove args
sudo grubby --update-kernel=ALL --remove-args="rhgb quiet"
# Verify grubby view
sudo grubby --info=DEFAULT | grep -E 'args|kernel'
After reboot:
cat /proc/cmdline
# must contain the new tokens; removed tokens must be gone
ALL vs DEFAULT: If the task says every kernel or you just installed updates, --update-kernel=ALL avoids “works only on the old default.” If only current matters, DEFAULT may be enough—read the task.
Change default kernel
sudo grubby --info=ALL | grep -E '^index=|^kernel='
# Set by kernel path:
sudo grubby --set-default /boot/vmlinuz-5.x.x-x.el10.x86_64
# or by index:
sudo grubby --set-default-index=0
sudo grubby --default-kernel
Kernel RPMs install new vmlinuz-* under /boot; default may stay on the newest depending on install scripts—explicitly set default when the task names a version.
/etc/default/grub and grub2-mkconfig
Classic durable pattern:
sudo cp -a /etc/default/grub /etc/default/grub.bak
sudo vim /etc/default/grub
Important variables:
| Variable | Meaning |
|---|---|
GRUB_TIMEOUT | Menu timeout seconds |
GRUB_DEFAULT | Default menu entry (saved/index) |
GRUB_CMDLINE_LINUX | Kernel args applied when config is generated |
GRUB_CMDLINE_LINUX_DEFAULT | Sometimes used for non-recovery style entries (distro-dependent; on RHEL focus on GRUB_CMDLINE_LINUX) |
GRUB_DISABLE_SUBMENU | Menu layout |
Example:
# Ensure a parameter is in GRUB_CMDLINE_LINUX="... existing ... audit=1"
grep GRUB_CMDLINE_LINUX /etc/default/grub
Regenerate config:
# BIOS-style path
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# UEFI-style path (RHEL)
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
On many RHEL systems a convenience wrapper exists:
sudo grub2-mkconfig -o $(readlink -e /etc/grub2.cfg 2>/dev/null || readlink -e /etc/grub2-efi.cfg 2>/dev/null)
# or follow Red Hat docs for the platform:
# BIOS: grub2-mkconfig -o /boot/grub2/grub.cfg
# UEFI: grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
ls -l /etc/grub2.cfg /etc/grub2-efi.cfg 2>/dev/null
Mismatch trap: Running grub2-mkconfig to the BIOS path on a UEFI VM (or the reverse) updates a file firmware does not use—boot looks unchanged. Detect EFI vs BIOS first, write the correct output path.
grubby vs grub2-mkconfig together
grubbyedits BLS/bootloader entries and is the least error-prone for args and default kernel on modern RHEL./etc/default/grub+grub2-mkconfigis the traditional regeneration path; still required knowledge when tasks mention those files.
If you use both, avoid fighting yourself: after heavy grubby use, understand that regenerating from /etc/default/grub re-applies GRUB_CMDLINE_LINUX to entries—keep that file consistent with desired args.
One-boot GRUB edit vs persistent change
| Method | Persistent? | Use |
|---|---|---|
| Edit menu entry once (e key) | No | Recovery, Ch8 |
grubby --args / --remove-args | Yes | EX200 deploy |
GRUB_CMDLINE_LINUX + grub2-mkconfig | Yes | EX200 deploy |
systemd.unit= only on one boot | No | Temporary target |
If the grader reboots twice, only persistent methods pass “configure the bootloader.”
Password and menu aesthetics (light touch)
EX200 focuses less on GRUB passwords than on cmdline and defaults. Still know:
grep GRUB_TIMEOUT /etc/default/grub
# change timeout, then grub2-mkconfig to the correct grub.cfg
Do not set a GRUB password unless asked—you can lock recovery paths.
Kernel install interaction
sudo dnf install -y kernel # may add a new entry
sudo grubby --info=ALL
sudo grubby --default-kernel
After kernel updates, confirm default and args still meet the task. Re-apply --update-kernel=ALL --args=… if a new kernel lacks required parameters.
Verification checklist
# 1) Before reboot
sudo grubby --info=DEFAULT
grep GRUB_CMDLINE_LINUX /etc/default/grub
# 2) Reboot
sudo systemctl reboot
# 3) After login
uname -r
cat /proc/cmdline
sudo grubby --default-kernel
Optional:
journalctl -b -0 | head
# confirm system came up with expected console/target behavior
Exam workflows
Workflow A — Persist a kernel parameter with grubby
sudo grubby --update-kernel=ALL --args="audit=1"
sudo grubby --info=DEFAULT | grep args
sudo systemctl reboot
# cat /proc/cmdline | grep audit=1
Workflow B — Remove quiet boot noise
sudo grubby --update-kernel=ALL --remove-args="rhgb quiet"
sudo systemctl reboot
cat /proc/cmdline
Workflow C — /etc/default/grub path
sudo vi /etc/default/grub # add token inside GRUB_CMDLINE_LINUX="..."
# UEFI example:
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
# BIOS example:
# sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo systemctl reboot
cat /proc/cmdline
Workflow D — Set default kernel to a specific version
ls /boot/vmlinuz-*
sudo grubby --set-default /boot/vmlinuz-WANTEDVERSION
sudo grubby --default-kernel
sudo systemctl reboot
uname -r # expect WANTEDVERSION
Workflow E — Confirm firmware path before mkconfig
if [ -d /sys/firmware/efi ]; then
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
else
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
fi
Common traps
- Only editing GRUB once at the menu—lost on next reboot.
grub2-mkconfigto the wrong path (BIOS vs UEFI).- Hand-editing only
grub.cfgwithout updating/etc/default/grubor using grubby—fragile. - Adding args to one old kernel while the system boots a newer default without those args.
- Typos in cmdline (
audit = 1with spaces may not mean what you want)—usekey=valueforms cleanly. - Forgetting reboot verification via
/proc/cmdline. - Confusing
systemctl set-default(target) with bootloader default kernel. - Removing critical args that break console or root device (rare on VMs but possible).
- Assuming
grubbyalone updated/etc/default/grub—keep mental model clear; verify withgrubby --infoand/proc/cmdline. - Kernel update overwriting expectations—re-check defaults after
dnf upgrade.
Relationship to other chapters
- Ch8 operate-boot: one-shot GRUB edits and rescue; this section owns persistence.
- 15.3 default target: prefer
systemctl set-defaultfor multi-user/graphical; bootloadersystemd.unit=is alternate/one-boot style unless task says bootloader parameter. - 16.2 software updates: new kernels → grubby defaults/args.
- Storage/root: cmdline
root=and rd.lvm settings are advanced; do not invent unless repairing a known lab breakage.
Section checkpoint
You should inventory entries with grubby --info=ALL, persistently add/remove kernel args, set the default kernel, edit /etc/default/grub and regenerate the correct grub.cfg with grub2-mkconfig, distinguish BIOS vs UEFI paths, avoid relying on one-boot menu edits for deploy tasks, and verify with cat /proc/cmdline after reboot. That is the EX200 standard for modifying the system bootloader on RHEL 10.
Which approach best adds a persistent kernel command-line parameter to all installed kernels on RHEL?
After a supposed bootloader change, which file best shows the kernel arguments used for the running system?
You are on a UEFI RHEL system and regenerate GRUB configuration. Which output path is the usual Red Hat UEFI location?
Which command identifies the current default kernel path as managed by grubby?