Adding OS entries in the GRUB menu


My goal was to show the GRUB menu at startup because I have Fedora on a SSD and Windows on another SSD. So by showing the GRUB I could be able to choose witch OS to boot without going in the BIOS menu.

I succeeded to show the GRUB menu. I’ve executed commands :
sudo grub2-editenv - unset menu_auto_hide
sudo grub2-mkconfig -o /etc/grub2.cfg

But I saw the latter command wasn’t necessary though. But it wrote on the terminal:
Generating grub configuration file ...
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration

So I was like “Cool I don’t even have to add the Windows boot entry to the GRUB menu, it did it automatically”. Unfortunately I restarted my computer, the GRUB menu appeared but I don’t have a Windows entry.

I’m trying to understand what have the sudo grub2-mkconfig -o /etc/grub2.cfg command done then ? Why it didn’t add the Windows boot entry to the GRUB menu. And therefore, how do I add it ?

Thank you.

  1. GRUB2 is Hidden by default if you don’t have another Operation System you don’t need to execute this command:

sudo grub2-mkconfig -o /etc/grub2.cfg

  1. You should know what system are you using EFI or BIOS:

On a system using UEFI booting ( “ls /sys/firmware/efi/efivars” returns files) you’re in a EFI:

sudo grub2-mkconfig -o /etc/grub2-efi.cfg

On a system using legacy BIOS boot:

sudo grub2-mkconfig -o /etc/grub2.cfg

You can also use this command to see what happened:

sudo grubby --info=ALL


NOTE: you’re typing a BIOS command in a EFI environment as you can see in this command


Ok so what this command : sudo grub2-mkconfig -o /etc/grub2-efi.cfg does is detecting other OS installed and creating a new grub2 config file. But it doesn’t create a new entry for the newly detected OS, right ? Because sudo grubby --info=ALL doesn’t show me an index for Windows.

Besides the link doesn’t explain for UEFI system, only for BIOS since it says " Install GRUB2 into the MBR"

What command do you need to know:

fdisk -l

What is the result of this command ls /sys/firmware/efi/efivars??

Are you in BIOS or EFI?
you can see a lot of file, if yes you’re in EFI

In this section talk about that:

If the system don’t detect maybe you have to add it manually, What version of windows we’re talking about?


Yes I’m in EFI.

sudo grubby --info=ALL still doesn’t show an entry for Windows, but on startup, a Windows entry is present. Although it doesn’t work. I get an error if I select it.

What is strange is sometimes it works, it boots Windows normally but much more often it shows me an error and put me back on the GRUB menu screen. Then when if I select Fedora it doesn’t work anymore, I have another error. However if I restart my computer and select Fedora first without trying Windows, it works.

The errors I get :
When I select Windows :
error: …/…/grub-core/commands/search.c:296: no such device: B49A-7BAE
error: …/…/grub-core/disk/efi/efidisk.c:518: invalid section size 65535

When I select Fedora after selecting Windows :
error: …/…/grub-core/disk/efi/efidisk.c:518: invalid section size 65535
error: …/…/grub-core/loader/i386/efi/linux.c:206: you need to load the kernel first

How can I restore the grub in its default configuration and add properly a Windows entry to the list ?

Press the letter “e” with the windows entry selected. Booting windows from grub essentially comes down to chainloading bootmgfw.efi, but…

…it seems as though grub is booting windows as it would a Linux kernel.

Edit: You have 32-bit UEFI? Could that be contributing to some of the weirdness? Could you send the output of rpm -qa grub* shim*?

No no no this error comes up when I select Fedora (after having selected Windows)

No I have a 64-bit system.

It returned :

I also noticed something. This link says, I quote :

For newly installed kernels to work, grubby expects /etc/grub2-efi.cfg to be a symlink to the real grub.cfg (for example /boot/efi/EFI/fedora/grub.cfg ).

But I was executing grub2-mkconfig commands on /etc/grub2-efi.cfg. This is the exact command I executed : sudo grub2-mkconfig -o /etc/grub2.cfg. The file I was executing the command on is supposed to be a symlink, isn’t it ? Maybe that’s where the mistake is. So I checked in my file explorer Nautilus the properties of the two files /etc/grub2-efi.cfg and /etc/grub2.cfg, it says : “Link (broken) (inode/symlink)”.

Oh, right. Sorry, I think you said it before.

“i386” is 32-bit. That being in your error message suggests that you’re loading 32-bit grub. Perhaps that is an issue if you’re booting 64-bit OSs. Personally, I delete the bootloader files that I don’t need with sudo dnf remove grub2*ia32* grub2*cdboot* grub2-pc* shim-ia32. You’re welcome to leave them, but can you send the output of sudo efibootmgr -v? That should say which architecture is booting.

grub2.cfg or grub2-efi.cfg?

That makes sense, nautilus is running as your user and the EFI partition is only accessible to root. Therefore, sudo grub2-mkconfig -o /etc/grub2.cfg should work, but I’m accustomed to putting in the full path, so sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg. I doubt that’s necessary though.

Looking back, I noticed that you said that windows is on a separate SSD, but grub finds bootmgfw.efi on sda2 (note: grub tools may be able to use sd* identifiers, but those are a kernel thing. Grub itself uses UUIDs. And it…

…apparently can’t find the EFI partition that it’s looking for), which either suggests that windows is on another partition, or that both OSs share an EFI partition. Either way, can you send sudo blkid -o list?

Finally, I’ll assume that if you were dual booting previously with fedora 29, it worked. You can therefore try disabling the new blscfg format by changing “GRUB_ENABLE_BLSCFG=true” to false in /etc/default/grub. It would be best to get everything working with the new format, but it’s up to you.

BootCurrent: 0003
Timeout: 1 seconds
BootOrder: 0003,0000,000F,0002,000E,0012,0014,0007,0013,0001,0004,0005
Boot0000* Windows Boot Manager HD(2,GPT,c0d3eb88-f413-48a4-9118-b60aa6fa5cf9,0xe1800,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.}...d................
Boot0001* UEFI:CD/DVD Drive BBS(129,,0x0)
Boot0002* TSSTcorp CDDVDW SH-224DB BBS(CDROM,,0x0)AMBO
Boot0003* Fedora HD(1,GPT,cd54f322-dde3-4172-a14d-ed2bc1baacf0,0x800,0x64000)/File(\EFI\FEDORA\SHIMX64.EFI)
Boot0004* UEFI:Removable Device BBS(130,,0x0)
Boot0005* UEFI:Network Device BBS(131,,0x0)
Boot0007 Realtek PXE B03 D00 BBS(Network,,0x0)AMBO
Boot000E* Samsung SSD 860 EVO 500GB BBS(HD,,0x0)AMBO
Boot000F* UEFI OS HD(1,GPT,cd54f322-dde3-4172-a14d-ed2bc1baacf0,0x800,0x64000)/File(\EFI\BOOT\BOOTX64.EFI)
Boot0012* Crucial_CT512MX100SSD1 BBS(HD,,0x0)AMBO
Boot0013 ST3000DM001-1ER166 BBS(HD,,0x0)AMBO
Boot0014* Generic STORAGE DEVICE 9451 BBS(HD,,0x0)AMBO

Well I executed both sudo grub2-mkconfig -o /etc/grub2.cfg then sudo grub2-mkconfig -o /etc/grub2-efi.cfg because I didn’t know what was the difference and which one to execute. But I have a UEFI system so let’s say the former was a mistake.

Just to be clear, I have 2 SSD and 1 HDD in my computer. The first SSD contains Windows 10 and is on the disk sda with 4 partition so from sda1 to sda4. The second SSD contains Fedora on the disk sdc. The disk sdb is just a HDD where I store films. This is the result of the lsblk command and sudo blkid -o list command :
non monté = not mounted
utilisé = used

I wasn’t dual booting before, I just recently bought a new SSD and installed Fedora 30 on it.

Anyway, I think I should reinitialize grub to its initial state. How could I do that ? Is reinstalling the grub packages enough ?

Interesting. I had thought that Linux defined itself as sda, but I suppose it actually comes down to the ports on the motherboard (I use a laptop with fedora installed to the sole SSD).

Okay, I thought that maybe grub’s new config format might be the problem. It still could be. Try upgrading grub2*, there were some fixes released recently.

I don’t think that dnf reinstall will replace the configuration. You could try ``sudo dnf remove grub2*; sudo dnf install grub2-efi-x64" but I’m not sure if it’s a good idea. Besides the fact that I’m not sure if ‘grub2-efi-x64’ will pull in everything necessary as dependencies (so if you see anything being uninstalled that isn’t then installed afterwards, probably install that too), grub2 might be a protected package, but even if not, it might not be the best idea to remove your bootloader if you aren’t both sure that you have to, and that you know what you’re doing and can fix things if they go wrong.