My laptop shipped with Windows 11.
I installed Fedora 38 (brtfs).
I installed Ubuntu 23.04 (ext4).
Now my pc boot with Ubuntu GRUB menu and there is no Fedora entry.
This is the output of fdisk:
sudo fdisk -l
/dev/nvme0n1p1 2048 534527 532480 260M EFI System
/dev/nvme0n1p2 534528 567295 32768 16M Microsoft reserved
/dev/nvme0n1p3 567296 753174527 752607232 358.9G Microsoft basic data
/dev/nvme0n1p4 753174528 754442239 1267712 619M Windows recovery environmen
/dev/nvme0n1p5 754442240 756539391 2097152 1G Linux filesystem
/dev/nvme0n1p6 756539392 817979391 61440000 29.3G Linux filesystem
/dev/nvme0n1p7 817979392 1000212479 182233088 86.9G Linux filesystem
I found out that:
Ubuntu’s GRUB is installed in /dev/nvme0n1p7/boot/grub (same device with Ubuntu)
Fedora’s GRUB is installed in /dev/nvme0n1p5/grub2 and Fedora is in /dev/nvme0n1p6/root
What I have tried:
Enabled OS-prober
sudo update-grub
Run boot-repair on Ubuntu
Manually add Fedora entry in /etc/grub.d/40_custom. If I choose this custom entry, my PC shows Fedora’s GRUB menu, but there is only option to boot to Windows in this menu.
It seems that ubuntu’s grub overwrote fedora grub and does not see fedora for booting.
It may be necessary to boot to a live fedora media and mount the fedora partitions (probably btrfs on /dev/nvmeon1p6) with /boot as ext4 on p5 and /boot/efi on p1
Once everything is properly mounted then one would chroot into the fedora file system and reconfigure grub to boot fedora.
This is often a problem seen when installing multiple linux distros since the last one installed tends to take over grub for booting
Thanks for your reply.
Do you have any suggestion for the reconfigure grub procedure?
The best result for me will be Fedora showed up in Ubuntu’s grub menu.
You missed mounting the fedora /boot/efi in that list (which probably should be /dev/nvme0n1p1 and identified by its UUID in /etc/fstab). Thus the grub update did not properly configure the boot.
Also, one must confirm that /boot/efi is properly identified in /etc/fstab and that the proper efi partition is being used for boot.
If you enter the uefi setup screen which partition is shown as booting in the boot order list there.?
Also, what is the output of efibootmgr?
Sorry my bad, I did mount the efi partition to /mnt/boot/efi too but I forgot to type it. But to make it sure I just did it again. This is all the step:
sudo mount -t btrfs -o subvol=root,compress=zstd:1 UUID=5d0ed25f-9df2-4575-bb37-a474cb3ae3d3 /mnt
sudo mount /dev/nvme1n1p5 /mnt/boot
sudo mount /dev/nvme1n1p1 /mnt/boot/efi
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount --bind /run /mnt/run
sudo mount --bind /proc /mnt/proc
sudo chroot /mnt
grub2-mkconfig -o /boot/grub2/grub.cfg
And the output:
Generating grub configuration file …
Found Windows Boot Manager on /dev/nvme1n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu 23.04 (23.04) on /dev/nvme1n1p7
Adding boot menu entry for UEFI Firmware Settings …
done
I do not understand why fedora would give that error for efibootmgr when the fstab shows an efi partition the same as ubuntu uses. It would appear this may be the underlying cause of fedora not being seen by grub.
Your output from grub2-mkconfig seems exactly what would be expected and as long as the bios can select the proper entry for grub it should work.
Ubuntu grub seems to have a problem booting fedora in several posts here, but fedora seems to not have problems with booting ubuntu once the system is set up properly and only uses the fedora grub.
One fix, though it seems extreme, may be to do a dnf reinstall grub2* shim* kernel* while booted into the chroot environment you show above. It would seem that one needs to get the bios to recognize fedora grub again.
I tried it but nothing changed. There is no Fedora entry in both Ubuntu and Fedora grub.
I tried grub2-mkconfig again but nothing changed too.
I just noticed there are a lot of warning when reinstall grub2 shim & kernel.
Here is the output log https://pastebin.com/EFQp6Vw3
This usually means that this OS has not been booted in UEFI mode. To reduce confusion, it might be a good idea to disable the CSM mode, that is, disable the ability to boot in non-UEFI mode.
OK so this is where the problem come from. the /sys/firmware/efi/efivars was not mounted.
This time I tried mount the /dev and /sys using –rbind instead of -bind:
sudo mount --rbind /sys /mnt/sys
sudo mount --rbind /dev /mnt/dev
OK I noticed something very weird. My pc has two Fedora grub menu.
If I access the grub from shimx64.efi it showed everything (Fedora entries, Ubuntu entries, Windows entry).
Once I’m inside Fedora, I ran grub customizer and all the Fedora entries disappeared:
If I may make a guess, grub from Ubuntu does not understand the bls snippets you will find in Fedora’s grub. Otherwise, the added snippet looks fine to me. It is likely you can only multi-boot Fedora and Ubuntu by first loading Fedora’s grub2, and from there refer to the Ubuntu grub.cfg.
Is grub-customize a package from fedora? I don’t seem to find it or similar.
If it is from a 3rd party then it may not function within fedora as one might expect.
Correction: I found it as grub-customizer.
On my dual boot F38 system I see this:
Hmmm OK so my situation is normal
Somehow I feel like the /boot/grub2/grub.cfg loads only other OS entries as default.
EDIT: ok I found the answer. So it’s all about the BLS option.
When BLS support is enabled (GRUB_ENABLE_BLSCFG=true), GRUB will read the BLS entries and configuration files to generate the GRUB menu. This allows for easier management of multiple kernel and initramfs images, including options like fallback images and kernel parameters defined in BLS.
On the other hand, when BLS support is disabled (GRUB_ENABLE_BLSCFG=false), GRUB will not consider BLS entries and will use the traditional configuration files (such as /etc/default/grub and /etc/grub.d/*) to generate the GRUB menu.