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 make 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
Bash
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 Bash
-
nano
(easy to use command-line editor)sudo nano /etc/default/grub Bash
-
gedit
(editor with graphical interface, default text editor of Ubuntu and distros with GNOME)sudo gedit /etc/default/grub Bash
or
gedit admin:/etc/default/grub Bash
/etc/default/grub
opened withgedit
Add or edit the parameters GRUB_DEFAULT
and GRUB_SAVEDEFAULT
:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
Plain text
Make GRUB Configuration
Generate GRUB configuration:
-
Debian/Ubuntu based Linux
sudo update-grub Bash
-
Arch Linux/Manjaro
sudo grub-mkconfig -o /boot/grub/grub.cfg Bash
-
RHEL/CentOS/Fedora
sudo grub2-mkconfig -o /boot/grub2/grub.cfg Bash
Now reboot and the selected boot option will be remembered next time.