2

I have a dual boot system with CentOS 7 and Win10. My install was totally vanilla (CentOS then Win10) and went fine. Everything is great except that grub does not appear to save my "last" choice from the boot load menu.

I dug through all the grub configuration files (e.g. /boot/efi/EFI/centos/grub.cfg) and all the code seems there for recording the last choice.

My /etc/default/grub shows:

GRUB_TIMEOUT=5
...
GRUB_DEFAULT=saved
...
GRUB_SAVEDEFAULT=true

Is there anything obvious I am missing or need to do to enable this?

My /etc/efi/EFI/centos/grubenv never apperas to record the latest selection. It always has:

saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
##########[...snip...padding to 1k]

I can't see this file from a Windows boot, but I did test via the "rescue Centos entry".

I manually set the value in grubenv to Windows Boot Manager (on /dev/sda2) (the Windows entry) and this works out okay. However, booting back into CentOS fails to change it.

It just seems I am missing something to enable this "save the last choice" behavior. Any ideas?

  • 1
    have you ran sudo update-grub after editing these files? – Luca D'Amico Apr 21 '16 at 18:47
  • I never modified anything. This was all created by the install process? (Or part of the installed image?) – Tim Apr 22 '16 at 8:50
0

Alternatively, you can simply specify the number for GRUB_DEFAULT for the OS you want to set as default. Go the grub configuration file located at /boot/grub2/grub.cfg and search for the keyword menuentry. This will have the OS listing that will appear on the boot screen.

Assuming CentOS entry is first and then Windows entry, if you want the default OS to boot as CentOS, simply edit the value for GRUB_DEFAULT in /etc/default/grub as follows

GRUB_DEFAULT=0

If you want Windows 10 to be booted as default, then set

GRUB_DEFAULT=1

Save and reboot. You should be getting your selected OS as default.

0

The /etc/default/grub file is used to generate the final grub.cfg file that actually governs the behavior of grub. After editing the grub file you have to run

sudo update-grub

to generate a new /boot/grub/grub.cfg (usual location).

0

Realizing this question is almost a year old, I can confirm the following works:

$ su
Password:
# vim /boot/grub/grub.conf

Within the file, I have the following:

default=saved
timeout=5
...
title CentOS (2.6.32-642.13.1.el6.x86_64)
    root ...
    ...
    savedefault
    initrd ...
title CentOS (<old kernel>...)
    ...
    savedefault
title Windows (10)
    ...
    savedefault

I think you might be missing the savedefault keyword(?) in each boot entry - although it also looks like you might be on CentOS 7, and I'm on CentOS 6. IIRC, CentOS 6 uses GRUB (GRUB v1.97), while CentOS 7 uses GRUB2 (GRUB 2.01).

I'm sure future users/searchers will appreciate any who can confirm/deny that this addresses their problem.

0

I can confirm that savedefault option is necessary in Centos 7.

What I did was create my custom entries in /etc/grub.d/40_custom making sure that savedefault was present.

And then updating the menu:

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

That's it!

0

According to This bug the issue lies with the link to grubenv pointing to /boot/grub2/grubenv, but /boot isn't mounted in the grub menu environment. The bug above is from fedora but I assume the same goes for centos. I'm having this issue running CentOS 7 and grub2.

System boots up just fine but only after pressing a key, dismissing the message that grubenv doesn't exist. The bug above includes a fix as well. Symlinking

/boot/grub2/grubenv -> ../efi/EFI/centos/grubenv

Should fix this issue.

  • Edit * Confirmed this solves the issue on CentOS 7.1 running linux kernel 4.20.0.1 .

How to?

sudo rm /boot/grub2/grubenv
sudo ln -s ../efi/EFI/centos/grubenv /boot/grub2/grubenv

Make sure you remove grub2-efi as well if you don't need it, as it seems to cause this issue.

sudo yum remove grub2-efi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.