Save last kernel used as grub's default
The Nvidia driver currently available in buster-backport (450.80) seems to have issues with the 5.9 kernel, resulting in an unavailable uvm module.
[ 8883.526038] nvidia_uvm: module uses symbols from proprietary module nvidia, inheriting taint.
[ 8883.526306] nvidia_uvm: Unknown symbol radix_tree_preloads (err -2)
[ 8883.526339] nvidia_uvm: Unknown symbol set_cpus_allowed_ptr (err -2)
[ 8883.526380] nvidia_uvm: Unknown symbol mmu_notifier_unregister (err -2)
[ 8883.526485] nvidia_uvm: Unknown symbol __mmu_notifier_register (err -2)
The next release (455.+) was said to fix this but has yet to reach the backports repository. In the meantime, sticking to the 5.8 kernel is the easiest workaround. But I keep forgetting to change the selection at boot time: power on the computer, untangle the mouse cord, look at the screen and it’s already on the login. Speedy NVMe are great but better not blink . Thus, I first thought of forcing grub to use the second entry as default and found these lines:
> grep DEFAULT /etc/grub.d/*
...
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
...
So instead of hardcoding a value, it turns out we can also load a previously saved entry, just by setting the two following variables in /etc/default/grub and running update-grub.
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
The first line enable the default selection based on the saved value, the second set the default value on the current selection (thus a manual change on the grub menu is all that’s required to update the saved default). Looking in the /boot/grub/grub.cfg, we can see the additional command savedefault at the beginning of each menuentry section.
Probably not a recent feature, but it is neat to find out your odd use-case is already handled nicely in the configuration files.