Page 1 of 1

make grub default to last boot

Posted: 2019/11/02 22:25:15
by ezekiyovel@gmail.com
Hello,

I have just installed centos 8 alongside windows 10, and grub shows a menu with three centos entries and windows, with first entry as default.
I want grub to always pre-select the entry I used last boot, e.g. if at some point I boot windows I want the fourth entry in the grub menu (the windows entry) to be pre-selected and the same with centos.
I read here: https://wiki.centos.org/HowTos/Grub2 that this could be achieved by having the next two lines in the /etc/default/grub file:

Code: Select all

GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
and than re-creating the grub boot menu using the command:

Code: Select all

grub2-mkconfig -o /boot/grub2/grub.cfg
but I must be misunderstanding something because it doesn't work.
here is my /etc/default/grub:

Code: Select all

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
hopefully someone can help me find out how to make my grub always default to load last used os.

Re: make grub default to last boot

Posted: 2019/11/03 02:39:36
by TrevorH
That doesn't look like a wise thing to run. What do you think it is going to do?

Re: make grub default to last boot

Posted: 2019/11/03 16:30:35
by nouvo09
Just be carefull what you are talking about.

BLSCFG=enable means that the fedora boot informations are no more picked up from the grub.cfg file but in the /boot/loader/entries directory where every version stores its boot information.

By the way the grub loader does not take care of the last boot also if corresponding options are in the /etc/default/grub file. Instead, grub reads these entries sorted by ALPHABETIC ORDER and as you can see, the corresponding names always begin with the UUID.

So, starting with BLS enabled, grub displays the menu choices by alphabetic order of UUID.

The only way to fix that is to change GRUB_ENABLE_BLSCFG to false and regenerate the grub. cfg file.