Make GRUB Remember Your Last Booted Operating System
On my laptop I dual-boot between Windows and Ubuntu. Because I switch back and forth quite often, one of the recurring frustrations is that the system rarely boots into the OS I actually need at that moment. For example, when the default is set to Ubuntu and I am running Windows updates, the laptop might reboot several times. If I am not there to press the arrow keys before GRUB loads, it will end up booting Ubuntu instead of continuing the update process.
A simple way to improve this situation is to tell GRUB to remember the last selected boot option. Fortunately, GRUB supports this out of the box.
To enable this behavior, edit /etc/default/grub and set GRUB_DEFAULT to saved. Then add GRUB_SAVEDEFAULT=true. It should look like this:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
Then run the following command to apply the changes:
sudo update-grub
The GRUB documentation explains GRUB_DEFAULT as follows:
If you set this to
saved, then the default menu entry will be that saved byGRUB_SAVEDEFAULTorgrub-set-default.
It also describes GRUB_SAVEDEFAULT with the following:
If this option is set to
true, then, when an entry is selected, save it as a new default entry for use by future runs of GRUB. This is only useful ifGRUB_DEFAULT=saved; it is a separate option becauseGRUB_DEFAULT=savedis useful without this option, in conjunction withgrub-set-default.
In short, when GRUB_DEFAULT=saved is enabled, GRUB loads the default entry from a stored configuration. You can set this default manually with grub-set-default, or you can let GRUB update it automatically every time you select a boot option by enabling GRUB_SAVEDEFAULT=true.
No comments yet
// Your email address will not be published.