Chapter 8. Building a customized boot menu You can build a boot menu containing specific entries or change the order of the entries. For such a task, you can use GRUB, grubby , and Boot Loader Specification ( BLS ) files. The following sections provide information about using GRUB and grubby to do basic customization of the boot menu. 8.1. The GRUB configuration file Learn about the boot loader configuration file that is /boot/grub2/grub.cfg on BIOS-based machines and /boot/efi/EFI/redhat/grub.cfg on UEFI-based machines. GRUB scripts search the user's computer and build a boot menu based on what operating systems the scripts find. To reflect the latest system boot options, the boot menu is rebuilt automatically when the kernel is updated or a new kernel is added. GRUB uses a series of scripts, located in the /etc/grub.d/ directory, to build the menu. The scripts include the following files: 00_header , which loads GRUB settings from the /etc/default/grub file. 01_users , which reads the root password from the user.cfg file. 10_linux , which locates kernels in the default partition of Red Hat Enterprise Linux. 30_os-prober , which builds entries for operating systems found on other partitions. 40_custom , a template used to create additional menu entries. GRUB reads scripts from the /etc/grub.d/ directory in alphabetical order and therefore you can rename them to change the boot order of specific menu entries. 8.2. Hiding the list of bootable kernels You can prevent GRUB from displaying the list of bootable kernels when the system starts up. Procedure Set the GRUB_TIMEOUT_STYLE option in the /etc/default/grub file as follows: Rebuild the grub.cfg file for the changes to take effect. On BIOS-based machines, enter: On UEFI-based machines, enter: Press the Esc key to display the list of bootable kernels when booting. Important Do not set GRUB_TIMEOUT to 0 in the /etc/default/grub file to hide the list of bootable kernels. With such a setting, the system always boots immediately on the default menu entry, and if the default kernel fails to boot, it is not possible to boot any kernel. 8.3. Changing the default boot entry with the GRUB configuration file You can specify the default kernel package type, and change the default boot entry. Procedure Specify which operating system or kernel must be loaded by default by passing its index to the grub2-set-default command, for example: GRUB supports using a numeric value as the key for the saved_entry directive in /boot/grub2/grubenv to change the default order in which the operating systems are loaded. Note Index counting starts with zero. Therefore, GRUB loads the second entry. With the installed kernel, the index value will be overwritten. Note You can also use grubby to find indices for kernels. For more information, see Viewing the GRUB Menu Entry for a Kernel . Optional: Force the system to always use a particular menu entry: List the available menu entries: Use the menu entry name or the number of the position of a menu entry in the list as the key to the GRUB_DEFAULT directive in the /etc/default/grub file. For example: Rebuild the grub.cfg file for the changes to take effect. On BIOS-based machines, enter: On UEFI-based machines:

Commands:
GRUB_TIMEOUT_STYLE=hidden
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
grubby --set-default-index=1 The default is /boot/loader/entries/d5151aa93c444ac89e78347a1504d6c6-4.18.0-348.el8.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-348.el8.x86_64
grubby --info=ALL
GRUB_DEFAULT=example-gnu-linux
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg