4.3 Changing the Default Boot Option
When the system starts, the boot options screen will appear and wait 5 seconds for the user to make an operating system choice. If no selection has been made before the timeout elapses, the default operating system will be started. On a newly configured system, the default operating system will be the standard (non-rescue) CentOS 8 image. This default can, however, be changed from within CentOS.
A range of boot configuration options (including the 5 second timeout and the boot RHGB settings outlined in “Installing CentOS 8 on a Clean Disk Drive”) are declared in the /etc/default/grub file which reads as follows on a new installation:
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=”crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”
GRUB_ENABLE_BLSCFG=true
The first step in changing the default boot system is to declare the GRUB_SAVEDEFAULT setting within this file:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
.
.
This setting allows a new default value to be saved within the boot configuration. Next, run the grub2-set-default command to change the default setting using a numbering system that counts the first option as 0. For the boot options shown in Figure 4-5 above, for example, the first CentOS entry is position 0 while the Windows 10 option is position 2. The command to make Windows 10 the default boot option, therefore, would read as follows:
# grub2-set-default 2
Check that the new setting has taken effect by running the following command:
# grub2-editenv list
saved_entry=2
kernelopts=root=/dev/mapper/cl-root ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet
boot_success=0
boot_indeterminate=0
Note that the saved_entry value is now set to 2. After changing the default, regenerate the boot configuration file as follows:
# grub2-mkconfig --output=/boot/grub2/grub.cfg
Reboot the system and verify that the boot menu defaults to the Windows 10 option and that Windows loads after the timeout expires.