7. Deploy, Configure, and Maintain Systems
πRed Hat Certified System Administrator (RHCSA β EX200)
The bootloader is a small program that runs first when your computer starts. Its job is to load the operating system. On Red Hat systems, the default bootloader is GRUB2 (GRand Unified Bootloader version 2).
Understanding and modifying GRUB2 is critical because it controls how your system boots, which kernel it uses, and even troubleshooting options if the system doesnβt start properly.
1. Understanding the Boot Process
Hereβs the basic flow:
- BIOS/UEFI β Your serverβs firmware starts and looks for a bootable disk.
- MBR/GPT β The bootloader (GRUB2) is located here.
- GRUB2 menu β GRUB2 shows the boot menu, lets you pick which kernel or OS to boot.
- Kernel β The Linux kernel starts, initializes hardware, and starts system services.
IT Example: In a server environment, if you have multiple kernel versions (like
5.15and6.1), GRUB2 lets you choose which one to boot. This is useful if a new kernel breaks a service.
2. GRUB2 Configuration Files
GRUB2 has two main files:
/etc/default/grub- This file contains the main settings for GRUB2.
- Common options:
GRUB_TIMEOUTβ How many seconds GRUB waits before booting the default OS.GRUB_DEFAULTβ Which kernel or menu entry boots by default.GRUB_CMDLINE_LINUXβ Add kernel parameters (e.g.,rd.lvm.lv=vg0/lvrootfor LVM systems).
/boot/grub2/grub.cfg- This is the generated GRUB menu file.
- You should not edit this file manually, because it is overwritten when you regenerate GRUB configuration.
3. Regenerating GRUB Configuration
After changing /etc/default/grub or other GRUB settings, you must regenerate the GRUB config file:
- On BIOS systems: grub2-mkconfig -o /boot/grub2/grub.cfg
- On UEFI systems: grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
IT Example: If you update the
GRUB_TIMEOUTto 10 seconds, running the above command ensures GRUB will actually wait 10 seconds before booting.
4. Changing the Default Kernel
If multiple kernels are installed:
- List available kernels in GRUB: awk -F\’ ‘/menuentry / {print $2}’ /boot/grub2/grub.cfg
- Set the default kernel:
- By index number: grub2-set-default 1
- By name: grub2-set-default “CentOS Linux (5.15.0-100.el8.x86_64) 8 (Core)”
- Verify default: grub2-editenv list
IT Example: On a production server, you might keep the last stable kernel as default but still keep a newer test kernel available for troubleshooting.
5. Adding Kernel Parameters
Kernel parameters can modify boot behavior:
- Temporary (for troubleshooting):
- At the GRUB menu, press
e, edit the kernel line, and press Ctrl+X to boot.
- At the GRUB menu, press
- Permanent:
- Edit
/etc/default/grub: GRUB_CMDLINE_LINUX=”rd.lvm.lv=vg0/lvroot crashkernel=auto” - Regenerate GRUB config.
- Edit
IT Example: You can add
singleto boot into single-user mode, useful for fixing a misconfigured service or forgotten root password.
6. Booting into Rescue or Emergency Mode
Sometimes, the system fails to boot normally. GRUB allows you to:
- Boot into rescue mode or emergency mode by editing the kernel line in GRUB:
- Add
rescueoremergencytolinux16orlinuxline.
- Add
- This boots the system with minimal services so you can repair it.
IT Example: If a critical service prevents normal boot, emergency mode lets you start only the root shell without networking or other services.
7. Managing GRUB on UEFI vs BIOS Systems
- BIOS (legacy):
- GRUB config:
/boot/grub2/grub.cfg - GRUB installation:
grub2-install /dev/sda
- GRUB config:
- UEFI:
- GRUB config:
/boot/efi/EFI/redhat/grub.cfg - GRUB installation:
grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=redhat
- GRUB config:
IT Example: UEFI systems are common in virtualized environments; correct installation ensures the VM boots after migration.
8. RHCSA Exam Key Points
For the exam, you should be able to:
- Identify the GRUB2 configuration files (
/etc/default/grub,/boot/grub2/grub.cfg) - Modify GRUB settings (timeout, default kernel, kernel parameters)
- Regenerate GRUB config using
grub2-mkconfig - Set the default boot kernel using
grub2-set-default - Boot into emergency/rescue mode for troubleshooting
- Know the difference between BIOS and UEFI GRUB locations
- Temporarily modify boot parameters at GRUB menu
Tip for exam: Practice editing
/etc/default/grub, regenerating GRUB, and rebooting into different kernels. The exam often asks you to change the default kernel or add kernel parameters.
β Summary Table
| Task | Command/Action | Notes |
|---|---|---|
| Show available GRUB entries | awk -F\' '/menuentry / {print $2}' /boot/grub2/grub.cfg | Lists all kernels |
| Set default kernel | grub2-set-default <index or name> | Permanent |
| Check default kernel | grub2-editenv list | Shows default boot entry |
| Edit kernel parameters temporarily | Press e in GRUB menu | Only for next boot |
| Edit GRUB config permanently | /etc/default/grub + grub2-mkconfig | Required after changes |
| Regenerate GRUB config (BIOS) | grub2-mkconfig -o /boot/grub2/grub.cfg | Must do after changes |
| Regenerate GRUB config (UEFI) | grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg | UEFI systems |
