Ubuntu 20.04 Essentials
上QQ阅读APP看书,第一时间看更新

5.3 Changing the Default Boot Option

When the system starts, the boot options screen will appear and wait 10 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 Ubuntu image. This default can, however, be changed from within Ubuntu.

A range of boot configuration options (including the 10 second timeout and the boot settings outlined in “Installing Ubuntu on a Clean Disk Drive”) are declared in the /etc/default/grub file which reads as follows on a new installation:

GRUB_DEFAULT=0

GRUB_TIMEOUT_STYLE=hidden

GRUB_TIMEOUT=10

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

GRUB_CMDLINE_LINUX=””

The first step in changing the default boot system is to declare the GRUB_SAVEDEFAULT setting within this file and to change the GRUB_DEFAULT setting to saved:

GRUB_DEFAULT=saved

GRUB_SAVEDEFAULT=true

GRUB_TIMEOUT_STYLE=hidden

GRUB_TIMEOUT=10

.

.

This setting allows a new default value to be saved within the boot configuration. Next, run the grub-set-default command to change the default setting using a numbering system that counts the first option as 0. For example, if the Windows 10 option is position 5 in the menu, the command to make Windows 10 the default boot option would read as follows:

# grub-set-default 4

Check that the new setting has taken effect by running the following command:

# grub-editenv list

saved_entry=4

Note that the saved_entry value is now set to 4. After changing the default, regenerate the boot configuration file as follows:

# grub-mkconfig --output=/boot/grub/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.