How to set Windows as default boot instead of Fedora 31

I’d like to change the default boot option from Fedora to Windows. I’ve tried to read the docs but I’m a bit confused.
If I show my sudo ls /boot/loader/entries I see

giuliohome@localhost ~]$ sudo ls /boot/loader/entries
1cb178663c5e44d1a4ff2c09f5819ae7-0-rescue.conf
1cb178663c5e44d1a4ff2c09f5819ae7-5.3.7-301.fc31.x86_64.conf

And the second conf (without rescue in its name) contains the title for Fedora 31
title Fedora (0-rescue-1cb178663c5e44d1a4ff2c09f5819ae7) 31 (Thirty One)
and other things
Then I see the Windows options by issuing another command:

[giuliohome@localhost ~]$ sudo grep -P "submenu|^menuentry" /boot/grub2/grub.cfg | cut -d "'" -f2
Windows Recovery Environment (on /dev/sda1)
Windows 7 (on /dev/sda2)

I’m confused because there is no way to see together Fedora and Windows entries and I’d like to do a modification but I’m afraid to do it wrong causing some damage
Btw, I also wonder why grubby is not recognized as a command

giuliohome@localhost ~]$ sudo grubby --default-kernel
sudo: grubby: command not found

Anyway, according to this doc paragraph, I think that I should do

grub2-set-default "Windows 7 (on /dev/sda2)"

Am I understanding it well? Is the above command correctly spelt (I’m not sure how to correctly render the "<submenu title><menu entry title>" part, so I simply copied from the output of the previous suggested command to list all possible menu entries) for my situation? Is it the safest way to change the boot default? After it, there is no need of a grub2-mkconfig -o /boot/grub2/grub.cfg, is there? Anything else I’m supposed to do/check?

Thank you for your kind support.

1 Like

Hello @giuliohome, and welcome. The link you provided seems a bit stale on the info, I would refer you to the Fedora Sys Admin Guide on the topic. You should be able to issue the following to see all menu entries grubby --info=all to get a listing of your menu entries. Then you can set the default kernel with grub2-set-default 'entry-number or name' and this should be able to be done without needing to remake the grub config file, since it makes the changes to a file sourced by grub.cfg.

1 Like
dnf search grubby
Last metadata expiration check: 7:37:39 ago on Fri 31 Jan 2020 11:17:42 AM +07.
=============================== Name Exactly Matched: grubby ===============================
grubby.x86_64 : Command line tool for updating bootloader configs
=================================== Name Matched: grubby ===================================
grubby-deprecated.x86_64 : Legacy command line tool for updating bootloader configs
dnf install grubby

PS:  I can’t test BLS modern approach there, because i’ve no Win’.

1 Like

You have a point I assume ?

Thank you both very much! Indeed I started by looking at the doc posted from @jakfrost but I was perplexed because grubby was missing in my installation.
I have installed grubby as suggested by @vits95, then when I execute the command sudo grubby --info=ALL (notice that it needs the uppercase letters and a root auth, even if I understand that mine is a BOOT not a UEFI) I still can’t see my third and fourth Windows entries (that I can get with the other command in my original post from the “stale” doc) but I only see:

[giuliohome@localhost ~]$ sudo grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.3.7-301.fc31.x86_64"
args="ro resume=UUID=1222fd0f-2c38-4634-b9e8-df5f70a5617d rhgb quiet"
root="UUID=169f454d-3ccf-4ed3-a633-9452941d6b44"
initrd="/boot/initramfs-5.3.7-301.fc31.x86_64.img"
title="Fedora (5.3.7-301.fc31.x86_64) 31 (Thirty One)"
id="1cb178663c5e44d1a4ff2c09f5819ae7-5.3.7-301.fc31.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-1cb178663c5e44d1a4ff2c09f5819ae7"
args="ro resume=UUID=1222fd0f-2c38-4634-b9e8-df5f70a5617d rhgb quiet"
root="UUID=169f454d-3ccf-4ed3-a633-9452941d6b44"
initrd="/boot/initramfs-0-rescue-1cb178663c5e44d1a4ff2c09f5819ae7.img"
title="Fedora (0-rescue-1cb178663c5e44d1a4ff2c09f5819ae7) 31 (Thirty One)"
id="1cb178663c5e44d1a4ff2c09f5819ae7-0-rescue"

Is it important the fact that I can’t see the Windows entries from the output above or can I safely ignore it?
Now, should I proceed with

grub2-set-default 'Windows 7 (on /dev/sda2)'

or

grub2-set-default 3

which one is better? So is it with single quotes ' and not double quotes " when used with a name, isn’t it? While it is followed by just a number in the second case (as per the example in the doc). From which command can I have confirmation that the number or the name of the Windows entry is correct? Thanks again.

First option doesn’t check the correctness:

cat /boot/grub2/grubenv
saved_entry=Windows 7 (on /dev/sda2)

But i’ve no Win’ at all.


Second option… doesn’t check the correctness too:

cat /boot/grub2/grubenv
saved_entry=99

But I’ve no so many entries.


Of course i’ve a copy of my original /boot/grub2/grubenv.

1 Like

Your first option works as expected. Thank you very much.

About grubby doesn’t see Win’:

This isn’t intended to support Win’:
Boot Loader Specification (systemd.io).

If your’re interested, please see the

ls /boot/loader/entries/

@giuliohome, It’s good to see you resolved your issue. There is also the grub-customizer GUI tool that I have only just noticed. I haven’t used it, but it is a part of the fedora repo. As for Grubby, it has been progressing towards a script for some time and now is totally such. The original Grubby is now grubby-deprecated for use on older ‘legacy systems’. The grub-customizer seems to have all the necessary bits, I think I will see how well it works on Silverblue.

@jakfrost just a little comment from my part about, grub-customizer doesn’t works well:

https://discussion.fedoraproject.org/t/grub-doesnt-error-with-background-image-module/74354/2

Regards.,

Two valid ways to do this.

  1. grub2-set-default
  2. efibootmgr --bootorder

The first option means the firmware checks NVRAM which points to shim which points to GRUB which points to Windows bootloader.

The second means NVRAM points to the Windows bootloader, bypassing shim+GRUB.

The first option can be interrupted by holding Esc to get the GRUB boot menu. The second, to boot Fedora, takes a trick in Windows: shift key+reboot then there’s an option to boot from another device ( tends vary depending on Windows version), and if you choose that you’ll see a Fedora option.

Still another way, most UEFI firmware have a (clunky) built in boot manager, typically accessed by F key shortcut.

1 Like

Finally!  Ubuntu way Shift-key holding didn’t worked to show GRUB menu at boot time, for me.

Yes, I have recently looked at it on my SB install and it sometimes works, sometimes states it is doing something but no showing what, process is shown as sleeping and I have to end it since it basically will go indefinitely sleeping from then on it seems. So @giuliohome, please don’t use the customizer as it seems unreliable at this moment.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.