Nixos-rebuild switch does not update boot entries

Hello!

I discovered some time ago that running sudo nixos-rebuild switch does not update the entries in /boot/loader/entries. When I boot, I always see the same invariant 66 entries last modified on October of 2020.

The symptoms are very much like this:

But my configuration of the boot partition seems to be correct as far as I can tell, and I haven’t changed the configuration of bootloaders or the mount points ever since.

$ mount | grep boot
/dev/nvme0n1p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

$ grep boot /etc/nixos/configuration.nix
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/nvme0n1";
  boot.loader.grub.configurationLimit = 100;

The configuration in /etc/nixos/hardware-configuration.nix looks correct as well

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/98B0-E4F6";
      fsType = "vfat";
    };

Any advice on debugging this is appreciated.

Thanks!

Is your boot partition full? 66 entries sounds like a lot.

Could you post the full output of nixos-rebuild boot?

The fact that your /boot is vfat makes me assume that you are on EFI, while at the same time your configuration screams for legacy boot. Which of these is true?

The boot partition is not full

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        794M     0  794M   0% /dev
tmpfs           7.8G  211M  7.6G   3% /dev/shm
tmpfs           3.9G   11M  3.9G   1% /run
tmpfs           7.8G  432K  7.8G   1% /run/wrappers
/dev/dm-0       219G  158G   51G  76% /
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/nvme0n1p1  549M  209M  341M  39% /boot
tmpfs           1.6G  244K  1.6G   1% /run/user/1000

I think I’m using efi since /sys/firmware/efi is present

$ ls /sys/firmware/efi
config_table  efivars  esrt  fw_platform_size  fw_vendor  runtime  runtime-map  systab  vars

Happy to do more checks.

Thanks for your thoughts.

And here’s the output of nixos-rebuild boot

$ sudo nixos-rebuild boot
building Nix...
building the system configuration...
updating GRUB 2 menu...

I discovered today that I can boot into the latest generations if I change the firmware to boot in legacy mode. For some reason, nixos stopped updating efi entries and only updates the legacy configuration. I wonder if there is some way to have both configurations updated.

I think that’s probably what @NobbZ meant. You need to set boot.loader.grub.efiSupport for, well, efi support.

Looking at the grub install script, it looks like there’s some support for doing both: nixpkgs/install-grub.pl at 4c560cc7ee57e1fb28e6fd7bdacdf01f948f8a91 · NixOS/nixpkgs · GitHub. I’m not sure it’s possible to hit that condition though, since grubTarget is what propagates there, and that can only be one or the other: nixpkgs/2.0x.nix at 4c560cc7ee57e1fb28e6fd7bdacdf01f948f8a91 · NixOS/nixpkgs · GitHub nevermind, I think both is the “default” if you set efi support? This script is hard to read without actually testing it.

2 Likes

Not only this, but for grub one needs to also set boot.loader.grub.device = "nodev" or something like that.

1 Like
Hosted by Flying Circus.