Duplicate entry in GRUB configuration

Hi, I don’t know if It is a miss-configuration or a bug. I have a duplicate entry in GRUB for the boot drive that prevent NixOS to start.

The configuration:

  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/disk/by-id/wwn-0x500a07510d62bf69";

Produce 2 entries in the GRUB config file /boot/grub/grub.cfg

menuentry "NixOS" --class nixos --unrestricted {
search --set=drive1 --fs-uuid 8ae24497-3a22-4a89-8a21-8a0151701c4e
search --set=drive2 --fs-uuid 8ae24497-3a22-4a89-8a21-8a0151701c4e
  linux ($drive2)/nix/store/303izw3zmxza3n01blxaa5a44abbqkkr-linux-6.12.30/bzImage init=/nix/store/0drzkd1ijpsj8yqbc482v55rznfiai1w-nixos-system-gintoki-25.05.20250528.7282cb5/init loglevel=4 lsm=landlock,yama,bpf,apparmor apparmor=1
  initrd ($drive2)/nix/store/kq0ix4f8vr64sv047nj78qbm5rnj306i-initrd-linux-6.12.30/initrd
}

I have manually delete and edit the file each time or do it in GRUB.

Are you using EFI boot? If so use nodev for the device.

There is only 1 xfs partition. I’ll try to disable EFI boot in the BIOS.

That’s not even remotely what I said.

If you’re using EFi boot, set boot.loader.grub.device = "nodev";. Then check if you still have issues.

sorry i thought of nodev the mount option for the filesystem.
i tried, the same file is generated with boot.loader.grub.device = "nodev";

I think we need to see more of your config, because it’s clear that some things are left out. For instance, I know that if you’re using EFI then you must be setting boot.loader.efi.efiSysMountPoint because otherwise kernels would be copied to the ESP and the menuentry would be searching for a FAT32 UUID which is only 8 hex characters. But you left this out so we’re missing information.

Anyway I’m able to replicate the redundant search command if I use a config like this:

    boot.loader.grub = {
      enable = true;
      efiSupport = true;
      device = "nodev";
    };

    fileSystems = {
      "/" = {
        device = "/dev/disk/by-uuid/ade2ed76-296d-4463-a36c-360da8889188";
        fsType = "xfs";
      };
      "/boot/efi" = {
        device = "LABEL=ESP";
        fsType = "vfat";
      };
    };

    boot.loader.efi.efiSysMountPoint = "/boot/efi";

I get a grub.cfg with menuentries for each generation that look like this:

menuentry "NixOS" --class nixos --unrestricted {
search --set=drive1 --fs-uuid ade2ed76-296d-4463-a36c-360da8889188
search --set=drive2 --fs-uuid ade2ed76-296d-4463-a36c-360da8889188
  linux ($drive2)/nix/store/303izw3zmxza3n01blxaa5a44abbqkkr-linux-6.12.30/bzImage init=/nix/store/xmm81b470gd6y8grwk73zlkjljzhif8c-nixos-system-target-test/init
  initrd ($drive2)/nix/store/g78l0l0fvgaajmn9hh670w6gm061mqhs-initrd-linux-6.12.30/initrd
}

But it boots just fine. I think the redundant search directive is not a problem. So what is the actual issue you’re observing?

1 Like