GRUB 2 reads its configuration from the /boot/grub2/grub.cfg file on traditional BIOS-based machines and from the /boot/efi/EFI/fedora/grub.cfg file on UEFI machines. This file contains menu information.
The GRUB 2 configuration file, grub.cfg, is generated during installation, or by invoking the /usr/sbin/grub2-mkconfig utility, and is automatically updated by grubby each time a new kernel is installed. When regenerated manually using grub2-mkconfig, the file is generated according to the template files located in /etc/grub.d/, and custom settings in the /etc/default/grub file. Edits of grub.cfg will be lost any time grub2-mkconfig is used to regenerate the file, so care must be taken to reflect any manual changes in /etc/default/grub as well.
Configuration files:
/boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
set pager=1
...[break]...
/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="resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
After making changes to /etc/default/grub
, you need to regenerate the GRUB config file with grub2-mkconfig
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
There are different ways to get information on what kernels are available:
You can list the available kernels with dnf. It checks the configured repos to see if there's an available kernel to download:
# dnf list kernel
Updating Subscription Management repositories.
Last metadata expiration check: 2:15:49 ago on Tue 24 Nov 2020 01:34:58 PM EST.
Installed Packages
kernel.x86_64 4.18.0-240.el8 @anaconda
kernel.x86_64 4.18.0-240.1.1.el8_3 @rhel-8-for-x86_64-baseos-rpms
RPM checks what the systems has installed:
# rpm -qa | grep kernel-[0-9]
kernel-4.18.0-240.1.1.el8_3.x86_64
kernel-4.18.0-240.el8.x86_64
grubby checks what's is configured in GRBU and what can be bootable from:
# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-4.18.0-240.1.1.el8_3.x86_64"
args="ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet $tuned_params"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-240.1.1.el8_3.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-240.1.1.el8_3.x86_64) 8.3 (Ootpa)"
id="b31bb9e7fc544e65beae56247bdd423f-4.18.0-240.1.1.el8_3.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-240.el8.x86_64"
args="ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet $tuned_params"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-240.el8.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-240.el8.x86_64) 8.3 (Ootpa)"
id="b31bb9e7fc544e65beae56247bdd423f-4.18.0-240.el8.x86_64"
index=2
kernel="/boot/vmlinuz-0-rescue-b31bb9e7fc544e65beae56247bdd423f"
args="ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-0-rescue-b31bb9e7fc544e65beae56247bdd423f.img"
title="Red Hat Enterprise Linux (0-rescue-b31bb9e7fc544e65beae56247bdd423f) 8.3 (Ootpa)"
id="b31bb9e7fc544e65beae56247bdd423f-0-rescue"
Use the arrows to select an option
You can use 'e' to edit additional parameters and boot
To identify what the current index is, use grubby --default-index
and it will show you:
# grubby --default-index
0
To change the default use
# grubby --set-default-index [#]
Or
# grubby --set-default [boot kernel line]
To change the default kernel use
# grub2-set-default 0
📝 NOTE: This section might be out of scope for the RHCSA exam
Steps:
Show mounts and partitions on drive
ls
Allows GRUB to handle LVM partitions (like for ls)
insmod lvm
Search partitions for config file
search.file /grub2/grub.cfg
View config file
cat
See man pages for: