Red Hat Enterprise Linux Diagnostics and Troubleshooting
Introduced in 2005, the Unified Extensible Firmware Interface (UEFI) replaces the original Extensible Firmware Interface (EFI) and the legacy BIOS. UEFI overcomes the limits of BIOS, such as 16-bit processor mode and 1 MiB of addressable space. UEFI supports booting from larger disks than 2 TiB, if the disk and its partitions use a GUID Partition Table (GPT) format.
UEFI systems and BIOS systems boot differently. A BIOS system must search for bootable operating systems on devices, while UEFI systems register bootable operating systems in the UEFI firmware. Users of UEFI systems can more easily select an operating system in a multiboot environment.
To boot a UEFI system with GRUB2, an EFI System Partition (ESP) must be present on the installed disk. It is recommended to use GPT partitioning for UEFI systems, although you can still use MBR partitioning. The ESP partition must be formatted with a FAT file system and be large enough to store the boot loader and all of the bootable kernels for operating systems that are installed on this system. The recommended size is 512 MiB, but a smaller size might be sufficient. The ESP partition is mounted at /boot/efi and is typically created by the anaconda installer.
A Secure Boot-capable system uses signatures on boot loaders, kernels, and other boot objects. The system firmware verifies the signatures as authentication that only unmodified code is being loaded, with a component that is known as the shim UEFI boot loader.
The shim.efi application is signed with a key that is trusted by common UEFI firmware. When executed, the shim.efi application attempts to load grubx64.efi with standard UEFI firmware calls. If the UEFI firmware cannot load the code because the signature does not authenticate, then the shim attempts to verify the application with other keys.
These alternative keys are either compiled into the shim, or read from a user-generated key that is stored in the UEFI NVRAM as the Machine Owner Key (MOK). When attempting to start a signed application for which no keys are registered, the MokManager.efi application starts automatically so that an end-user can register a personal key.
The shim.efi application registers an additional UEFI system call that uses GRUB2 to verify kernel signatures. If shim.efi is not registered with the UEFI firmware, then booting from the ESP partition executes the /boot/efi/EFI/BOOT/BOOTX64.efi application. This application loads the fallback.efi application, which automatically registers the shim.efi application and boots the system, based on the settings in /boot/efi/EFI/redhat/BOOT.CSV.
While most configuration syntax and tools remain the same for both BIOS and UEFI boot processes, some differences exist.
-
linux16and/initrd16changed tolinuxefiandinitrdefi The configuration commands to load a kernel and initial ramdisk switch from
linux16andinitrd16for BIOS tolinuxefiandinitrdefifor UEFI.This change is necessary because kernels must load differently on a UEFI system from on a BIOS system. The
grub2-mkconfigcommand automatically recognizes a UEFI system and uses the correct commands.-
/boot/grub2changed to/boot/efi/EFI/redhat The directory for holding the UEFI GRUB2 configuration files and objects is
/boot/efi/EFI/redhat. This directory is on the ESP partition for UEFI firmware access.-
grub2-install Do not use the
grub2-installcommand directly to install the UEFI boot loader. RHEL 8 provides a prebuilt/boot/efi/EFI/redhat/grubx64.efifile, which contains the required authentication signatures for a Secure Boot system. Executinggrub2-installdirectly on a UEFI system generates a newgrubx64.efifile without those required signatures. The correctgrubx64.efifile can be restored from thegrub2-efipackage.Use of
grub2-installdirectly registers a bootable target in the UEFI firmware with this newgrubx64.efiapplication, instead of the requiredshim.efiapplication.Warning
Use of the
grub2-installcommand generates and configures a genericgrubx64.efifile. If the system is configured for Secure Boot, then the system fails to boot.-
/boot/grub2/grub.cfgchanged to/boot/efi/EFI/redhat/grub.cfg The GRUB2 configuration file is moved from the
/boot/grub2directory for BIOS to the/boot/efi/EFI/redhat/directory on the ESP partition for UEFI. The symbolic link/etc/grub.cfgis moved to/etc/grub2-efi.cfg.
RHEL 8 provides the efibootmgr utility to manage and edit the available boot targets and logical boot order. The tool is in the efibootmgr package, which is installed by default on UEFI systems.
View the current targets with the efibootmgr command.
[root@host ~]#efibootmgrBootCurrent: 0003 Timeout: 0 seconds BootOrder: 0003,0002,0000Boot0000* UiApp Boot0002* UEFI Misc Device Boot0003* Red Hat Enterprise Linux
The list defines the order of the boot entries to try, from left to right. The numbers refer to the listed | |
This number is an individual boot entry; in this case, hexadecimal number |
View more information about boot entries by using the -v option.
[root@host ~]#efibootmgr -vBootCurrent: 0003 Timeout: 0 seconds BootOrder: 0003,0002,0000 Boot0000* UiApp FvVol(7cb8bdc9-f8eb-4f34-aaea-3ee4af6516a1)/FvFile(462caa21-7614-4503-836e-8ab6f4662331) Boot0002* UEFI Misc Device PciRoot(0x0)/Pci(0x2,0x3)/Pci(0x0,0x0)N.....YM....R,Y. Boot0003* Red Hat Enterprise Linux HD(1,GPT,e7e64bf7-6799-4791-bdc0-28147761e11d,0x800,0x12c000)/File(\EFI\redhat\shimx64.efi)
To remove a boot entry from the list, use the efibootmgr command with the -B option. In this example, the 0x0004 entry is deleted.
[root@host ~]# efibootmgr -b 4 -BUse the -n option to override the regular boot order for the current boot. For example, the following command forces the system to boot with entry 0x0002.
[root@host ~]# efibootmgr -n 2Use the -c option for creating new entries and boot numbers. Unless overridden on the command line, the option defaults to an ESP location on /dev/sda1, an intended label of Linux, and the boot loader application is elilo.efi.
The following example adds an Example entry, with /dev/sda2 as the ESP location, and with the /EFI/example.efi application on the ESP. In the application file name, you must replace forward slashes (/) with backslashes (\).
[root@host ~]# efibootmgr -c -d /dev/sda -p 2 -L "Example" -l "\EFI\example.efi"To generate BLS configuration files, enable the feature in the
/etc/default/grubfile.GRUB_ENABLE_BLSCFG=true
For a UEFI system, regenerate the
/boot/efi/EFI/redhat/grub.cfgfile.[root@host ~]#
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfgGenerating grub configuration file ... doneGenerate a kernel boot configuration in the
/boot/loader/entriesdirectory.[root@host ~]#
kernel-install add $(uname -r) /lib/modules/$(uname -r)/vmlinuz
On UEFI systems, using grubby requires root privileges.
Use grubby to obtain the file name of the default kernel.
[root@host ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-305.el8.x86_64Find the index number of the default kernel.
[root@host ~]# grubby --default-index
0Use the grubby command to persistently change the default kernel.
[root@host ~]# grubby --set-default /boot/vmlinuz-4.18.0-305.el8.x86_64
The default is /boot/loader/entries/e1a2445950a34804857a9407715ed7ab-4.18.0-305.el8.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-305.el8.x86_64List the kernel menu entries with details.
[root@host ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-4.18.0-305.el8.x86_64"
args="ro crashkernel=auto 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-305.el8.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-305.el8.x86_64) 8.4 (Ootpa)"
id="e1a2445950a34804857a9407715ed7ab-4.18.0-305.el8.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-e1a2445950a34804857a9407715ed7ab"
args="ro crashkernel=auto 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-e1a2445950a34804857a9407715ed7ab.img"
title="Red Hat Enterprise Linux (0-rescue-e1a2445950a34804857a9407715ed7ab) 8.4 (Ootpa)"
id="e1a2445950a34804857a9407715ed7ab-0-rescue"View the GRUB 2 menu entry for a specific kernel.
[root@host ~]# grubby --info /boot/vmlinuz-4.18.0-305.el8.x86_64
index=0
kernel="/boot/vmlinuz-4.18.0-305.el8.x86_64"
args="ro crashkernel=auto 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-305.el8.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-305.el8.x86_64) 8.4 (Ootpa)"
id="e1a2445950a34804857a9407715ed7ab-4.18.0-305.el8.x86_64"To recover damaged or missing /boot/efi files, reinstall the grub2-efi and shim packages.
[root@host ~]#yum reinstall grub2-efi shim---output omitted---Complete!
If the /boot/efi/EFI/redhat/grub.cfg file was removed, then you can regenerate it with grub2-mkconfig.
[root@host ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Generating grub configuration file ...
doneIf the Red Hat Enterprise Linux 8 entry is missing from the UEFI boot menu, it is automatically restored when you next boot from the UEFI-configured system disk.
References
efibootmgr(1), grub2-mkconfig(1), kernel-install(8) and grubby(8) man page
For further information, refer to Chapter 5. Configuring Kernel Command-Line Parameters at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/managing_monitoring_and_updating_the_kernel/configuring-kernel-command-line-parameters_managing-monitoring-and-updating-the-kernel
For further information, refer to How to reinstall GRUB and GRUB2 on UEFI-based machines? at https://access.redhat.com/solutions/3486741