GRUB2: how to remember grub last choice

As per the GRUB manual:

‘GRUB_DEFAULT’

.................

If you set this to ‘saved’, then the default menu entry will be that saved by ‘GRUB_SAVEDEFAULT’, grub-set-default, or grub-reboot.


‘GRUB_SAVEDEFAULT’

If this option is set to ‘true’, then, when an entry is selected, save it as a new default entry for use by future runs of GRUB. This is only useful if ‘GRUB_DEFAULT=saved’; it is a separate option because ‘GRUB_DEFAULT=saved’ is useful without this option, in conjunction with grub-set-default or grub-reboot. Unset by default. This option relies on the environment block, which may not be available in all situations (see Environment block).

You must add:

GRUB_DEFAULT=saved

and

GRUB_SAVEDEFAULT=true

to your /etc/default/grub. Also, if you are using custom menu files like /etc/grub.d/40_custom you must add the option

savedefault

to the menuentry/menuentries in that file. After that update GRUB:

grub-mkconfig -o /boot/grub/grub.cfg

or

update-grub

If you have several distros installed, make sure you are configuring and updating the active GRUB.