GRUB2
Configuration
-
/etc/default/grubcontains configuration options. -
rhgbandquietparameters are enabled by default and cause all output to be hidden when booting.rhgbis specific to the RHEL ecosystem. -
man 7 bootparamgives an overview of kernel boot parameters. -
Changes are not applied automatically; the
grub2-mkconfigcommand needs to be used to update a file in the boot, or EFI partitions. -
For BIOS systems the file is:
/boot/grub2/grub.cfgor/boot/grub/grub.cfg. -
For UEFI systems the file is:
/boot/efi/EFI/redhat/grub.cfgor/boot/efi/EFI/centos/grub.cfg -
For example:
grub2-mkconfig > /boot/grub2/grub.cfgorgrub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg -
/etc/grub.dcontains complex scripts to tell GRUB what order to load things in.
GRUB2 menu
Command mode
-
Press
cto enter command mode. -
In command mode, you can:
List disks and partitions with:
lsTo make GRUB LVM aware:insmod lvmSearch for a GRUB config file:search.file /grub2/grub.cfgCat a file:cat
Edit mode
-
Press
eto change boot parameters. -
The key line begins with the word linux; three recovery modes can be accessed by adding options to this line.
-
rd.break: breaks to an interactive shell while still in initrd. Doesn’t mount the system disk. The system disk appears as /sysroot.rd.breakis specific to the RHEL ecoysystem. -
emergency: likerd.breakbut mounts the system disk. -
recovery: more services thanemergencymode and the system disk mounted. -
After adding an option, press
^xto continue.
Resetting the root password for RHEL ecosystem distros
In an rd.break environment:
mount -o rw,remount /sysroot
passwd root
touch /.autorelabel
exit
mount -o ro,remount ./sysroot
reboot
-
The system will reboot twice and take some time to boot due to SELinux relabelling the filesystem.
-
/.autorelabel is necessary to relabel files with SELinux contexts.