Save previous choice in GRUB bootloader

Print

Q. I would like GRUB to remember my last OS choice and make that the selected option on the next boot. How do I do that?

A. This example is for GRUB2 - for GRUB 1 the options are slightly different.

Boot into Linux and make a backup of the following file:

sudo cp /etc/default/grub /etc/default/grub.bak

You can restore that file, if need be, using the following command:

sudo cp /etc/default/grub.bak /etc/default/grub

Using your favorite editor, modify this file:

sudo vim /etc/default/grub

Change

GRUB_DEFAULT=0

to

GRUB_DEFAULT=saved

and add the following line:

GRUB_SAVEDEFAULT=true

Save and close the file. Once done, update grub:

sudo update-grub

 

Linux