Duplicate /boot entries in mount output

I noticed that if I run nixos-rebuild switch a few times without rebooting, switches become slower and slower. While investigating something else I noticed that I have quite a few duplicate lines in my mount output (and mount takes a while to run as well)

❯ time mount | rg /boot | wc -l
mount  0.05s user 5.11s system 99% cpu 5.161 total
rg /boot  0.00s user 0.01s system 0% cpu 5.161 total
wc -l  0.00s user 0.00s system 0% cpu 5.161 total

I started paying attention to the output ofnixos-rebuild switch and I noticed this

updating GRUB 2 menu...
mount: /boot/efis/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086-part1: /dev/nvme0n1p1 already mounted on /boot/efis/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086-part1.
       dmesg(1) may have more information after failed mount system call.

And this seems to be the relevant message in my dmesg output

[123887.715384] systemd-gpt-auto-generator[951618]: EFI loader partition unknown, exiting.
[123887.715389] systemd-gpt-auto-generator[951618]: (The boot loader did not set EFI variable LoaderDevicePartUUID.)

I googled around but I’m not quite sure what it is that I should do. I think I should set that EFI variable but I’m at a loss at how to do that. I looked at the manual for efivar and there’s a flag to provide a name, but the name should be of “in the form 8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot0000” and I’m not sure how to come up with the right name myself.

fwiw, here’s my current configuration GitHub - alejandro-angulo/dotfiles at 00762bbc4ed870dd32303bf749f3f565d507b907 (this is not necessarily the commit that introduced that mount warning in my switch output – not sure when that started).

And here are the two duplicate lines I noticed in mount’s output

/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/nvme0n1p1 on /boot/efis/nvme-WDC_WDS100T2B0C-00PXH0_21111Y801086-part1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

(I guess remount-ro explains the duplicate mounts)

EDIT: Oh I forgot to mention, the relevant files in my config should be in the systems/x86_64-linux/gospel directory: https://github.com/alejandro-angulo/dotfiles/tree/00762bbc4ed870dd32303bf749f3f565d507b907/systems/x86_64-linux/gospel

This is a red herring, and definitely not what you need to be looking into. That’s about the discoverable partitions specification, which grub doesn’t support, and which your typical NixOS configuration isn’t using anyway (not sure NixOS would even support it tbh).

This is probably your problem:

  boot.loader.grub.extraPrepareConfig = ''
    mkdir -p /boot/efis
    for i in  /boot/efis/*; do mount $i ; done
    mkdir -p /boot/efi
    mount /boot/efi

This is running every nixos-rebuild and you’re over-mounting these things every time.

1 Like

Ah thanks so much for catching that. Thanks for steering me back on the right path!

Just to wrap this up, I ended up fixing with this change.

    for i in  /boot/efis/* ; do
      (mount | grep -q "$i")
      if (test $isDirectoryMounted -ne 0); then
        mount "$i"

Those file systems should already be mounted because of this. Why are you doing that at all?

1 Like

Ah I guess you’re right it’s redundant, thanks for catching that. I don’t have a good reason for this I’m just going to remove it (l checked git blame but it’s been there since my first nix config commit :grimacing: ).