Grub2-mkconfig finds image but doesn't add to menu

I have a NixOS installation on a different partition of the same disk as my Fedora 39. When I run the grub mkconfig it reports that it has found the NixOS image, yet when I reboot it is not listed on the grub menu. Any ideas for me?

Thanks in advance

You will need to add a config fragment so that your NixOS shows up.

Have a look in /etc/grub.d that has a place holder for custom entries.

You will need to research what needs to go into the file.

cat README 

All executable files in this directory are processed in shell expansion order.

  00_*: Reserved for 00_header.
  10_*: Native boot entries.
  20_*: Third party apps (e.g. memtest86+).

The number namespace in-between is configurable by system installer and/or
administrator.  For example, you can add an entry to boot another OS as
01_otheros, 11_otheros, etc, depending on the position you want it to occupy in
the menu; and then adjust the default setting via /etc/default/grub.

Have you tried anything from the NixOS side?

I think nixos-rebuild switch wil rebuild your Nix config ?

NixOS might have OS detection disabled. boot.loader.grub.useOSProber = true; in your configuration.nix file.

Thank you for the replies and the leads.

I will try to figure out how to write the custom entries. (I’m a lilo/elilo refugee and haven’t ever done that.) I’m not sure what to do with the README, since ordering isn’t an issue, just getting it to appear is my problem. I’ll try chrooting into nixos and rebuilding with the proposed setting as well.

Cheers

(The background is that I installed Fedora on a system with Nixos and I lost the Nixos entries.)

You could also try sudo grub2-mkconfig -o /boot/grub2/grub.cfg in Fedora.

1 Like

Added grub, nix

Thanks. I actually ended up just reinstalling NixOS… which wiped out Fedora’s boot… so now I have the opposite problem lol. I’ll get it right eventually. I can do work, which is what matters.

If you are still having trouble, installing one of the two distros without a boot loader might be the way to go. You will hten have to reconfigure it manually.

Install NixOS without Grub, then log back in to Fedora. Mount the NixOS partition and systemd-nspawn or chroot into it and run the Grub-mkconfig from there. I could probably provide more detailed instructions if needed. . .

Thanks. My current situation is that I believe in installing NixOS it overwrote the efi partition which Fedora was using, despite the misleading offer in Nixos installer to install beside another installation. I need to change my boot in Nixos to grub from the default systemd I think and then get Fedora to regenerate the efi stub and add it to the boot partition. Is that right? (I used lilo/elilo most of my life and still have a foggy understanding of grub).

If you are using systemd-boot ( which i use as well ) Fedora works just fine with it and it’s a much cleaner install IMO, but that all depends on what you want and are comfortable with.

So if I stick with the systemd boot how can I add Fedora to my boot menu? I have no particular interest in grub.

Thanks for your time.