You can adjust grub to save your last manual selection of a kernel-version or an installed OS to be used as the new default for further sessions.
As long you do not select a different entry manually again, the last selection will be used as default on recurrent boots without the need to enter grub-menu.
The grub-saved feature requires, that /boot/grub does reside on a supported filesystem like ext4/3/2. If /boot/grub resides at a btrfs-volume for example, grub will deny to save the user-selection as new default.
To make use of the grub-saved feature, one has to adjust /etc/default/grub and recreate the grub-menu afterwards.
It's generally a good idea to create a backup of system config-files - like /etc/default/grub - before editing them.
If using commands with sudo, you will get ask for your users password. (with older mint-versions, your will get no feedback shown while entering it; newer mint-versions will show some asterisks * while entering it)
The tutorial does show the output and values of a mint 19.3 -version. If you are using a different version of linux mint, your default-values might differ in details (but the related entries should still be spotable).
Copy the following line to a terminal:
df -Th /boot/grub
This should show some similar output:
Filesystem Type Size Used Avail Use% Mounted on /dev/sda5 ext4 61G 33G 25G 58% /
- where the column Type is important and should show preferable 'ext4', 'ext3' or 'ext2'.
If the shown type is 'btrfs', you can stop here, as grub does not support the grub-saved feature in this case.
Copy the following lines to a terminal:
mkdir ~/backups cp --parents --backup=numbered /etc/default/grub ~/backups
This will create a folder backups at your users home-directory and place a copy of the original file, including it's parent folders structure there.
If the cp command is run repeatedly, older backups will be kept, but renamed to grub~1~, grub~2~ etc - the last recent version will keep the original name.
Copy the following line to a terminal and enter your password, when being asked (2 times on the first run):
Note: If you cant used xed for some reason or are limited to a text-console, you can use nano - see IRC:nano.htm - instead to apply the required changes:
sudo nano /etc/default/grub
Replace the line showing GRUB_DEFAULT=0 with GRUB_DEFAULT=saved
Add a new line below GRUB_SAVEDEFAULT=true
Replace the line showing GRUB_TIMEOUT=0 with GRUB_TIMEOUT=3
If you want to display the grub-menu on boot without an user action, you can optionally replace GRUB_TIMEOUT_STYLE=hidden with GRUB_TIMEOUT_STYLE=menu
The final file will look similar to this (edit's are highlighted, leading and subsequent text is omitted)
# ... skipped text before # info -f grub -n 'Simple configuration' GRUB_DEFAULT=saved GRUB_SAVEDEFAULT=true GRUB_TIMEOUT_STYLE=menu # optional to show the grub-menu without user action GRUB_TIMEOUT=3 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # skipped text after ...
Save your changes and close the editor.
To re-create the actual grub-menu run:
, which should list available kernels and installed OS - similar to this:
oadm@mint-19-3-cinnamon-64bit:~$ sudo update-grub [sudo] password for oadm: Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/50_linuxmint.cfg' Sourcing file `/etc/default/grub.d/60_mint-theme.cfg' Generating grub configuration file ... Found theme: /boot/grub/themes/linuxmint/theme.txt Found linux image: /boot/vmlinuz-5.3.0-26-generic Found initrd image: /boot/initrd.img-5.3.0-26-generic Found linux image: /boot/vmlinuz-5.0.0-37-generic Found initrd image: /boot/initrd.img-5.0.0-37-generic Found linux image: /boot/vmlinuz-5.0.0-32-generic Found initrd image: /boot/initrd.img-5.0.0-32-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin done oadm@mint-19-3-cinnamon-64bit:~$
If update-grub does show any errors: recheck your edits. It might help to compare your edits against the initial created backup-file using:
diff /etc/default/grub ~/backups/etc/default/grub
oadm@mint-19-3-cinnamon-64bit:~$ diff /etc/default/grub ~/backups/etc/default/grub 6,9c6,8 < GRUB_DEFAULT=saved < GRUB_SAVEDEFAULT=true < GRUB_TIMEOUT_STYLE=menu < GRUB_TIMEOUT=3 --- > GRUB_DEFAULT=0 > GRUB_TIMEOUT_STYLE=hidden > GRUB_TIMEOUT=0 oadm@mint-19-3-cinnamon-64bit:~$
If you reboot now - and select a different kernel-version (or another OS) from the grub-menu withing the 3 seconds timeout - this will be used as your new default on following reboots until you change your selection again next time.
|IRC:nano.htm||a simple text-mode editor|
|IRC:grubedit.htm||making kernel params permanent|
|IRC:bootparam.htm||edit kernel params on boot, common use-cases|