make grub default to last boot

Issues related to applications and software problems and general support
Post Reply
ezekiyovel@gmail.com
Posts: 1
Joined: 2019/11/02 22:15:06

make grub default to last boot

Post by ezekiyovel@gmail.com » 2019/11/02 22:25:15

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.

User avatar
TrevorH
Site Admin
Posts: 33220
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: make grub default to last boot

Post by TrevorH » 2019/11/03 02:39:36

That doesn't look like a wise thing to run. What do you think it is going to do?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

nouvo09
Posts: 184
Joined: 2009/09/19 19:21:36
Location: Paris, France

Re: make grub default to last boot

Post by nouvo09 » 2019/11/03 16:30:35

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.
Member of centos-FR forum

Post Reply