Make GRUB (GRUB2) Remember Last Choice on Linux
Having multiple boot options managed by a boot manager like GRUB is a common thing on Linux or a Windows dual-boot machine, but to select the os/kernel in a 5 seconds window is a pain in the ass. So how about making GRUB remember your last boot choice?
Backup GRUB
First, backup your current GRUB configuration /etc/default/grub
to /etc/default/grub.backup
, in case anything goes wrong:
$ sudo cp /etc/default/grub /etc/default/grub.backup
Edit GRUB
Open the GRUB configuration /etc/default/grub
with the text editor of your choice:
-
vim
(command-line editor for advanced user)$ sudo vim /etc/default/grub
-
nano
(easy to use command-line editor)$ sudo nano /etc/default/grub
-
gedit
(editor with graphical interface, default text editor of Ubuntu and distros with GNOME)$ sudo gedit /etc/default/grub
or
$ gedit admin:/etc/default/grub
Add or edit the parameters GRUB_DEFAULT
and GRUB_SAVEDEFAULT
:
/etc/default/grubGRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
Plain text
Make GRUB Configuration
Generate GRUB configuration:
-
Debian/Ubuntu-based Linux
$ sudo update-grub
-
Arch Linux/Manjaro
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
-
RHEL/CentOS/Fedora
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Now, the selected boot option will be remembered for the next boot up.