Incorrect (stale) disk-uid during systemd initialisation

Hi, I created a new disk with btrfs yesterday. This is the config I used for nixos-install:


  # LUKS Encryption
  boot.initrd.luks.devices = {
      enc = {
          device = "/dev/disk/by-uuid/8d24cbb7-ba15-49cf-a6ff-e58a7a3ee4e0";
          preLVM = true;
          allowDiscards = true;
      };
  };

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=root" "compress=zstd" "noatime" ];
    };

  fileSystems."/home" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=home" "compress=zstd" ];
    };

  fileSystems."/nix" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=nix" "compress=zstd" "noatime" ];
    };

  fileSystems."/home/${current.user}/.local/share/steam" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=steam" "compress=zstd" "noatime" ];
    };

  fileSystems."/home/${current.user}/.local/virt" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=virt" "compress=zstd" "noatime" ];
    };

  fileSystems."/swap" =
    { device = "/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8";
      fsType = "btrfs";
      options = [ "subvol=swap" "noatime" ];
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/EB00-8E11";
      fsType = "vfat";
    };

  #swapDevices = [ { device = "/swap/swapfile"; } ];

When I restart my pc, I keep getting this waiting for disk and a hibernation resume error.

Mar 22 01:24:36 localhost systemd[1]: dev-disk-by\x2duuid-b3bbf535\x2df6ea\x2d4a46\x2dbd46\x2d813a542993af.device: Job dev-disk-by\x2duuid-b3bbf53
5\x2df6ea\x2d4a46\x2dbd46\x2d813a542993af.device/start timed out.
Mar 22 01:24:36 localhost systemd[1]: Timed out waiting for device /dev/disk/by-uuid/b3bbf535-f6ea-4a46-bd46-813a542993af.
Mar 22 01:24:36 localhost systemd[1]: Dependency failed for Resume from hibernation.
Mar 22 01:24:36 localhost systemd[1]: systemd-hibernate-resume.service: Job systemd-hibernate-resume.service/start failed with result 'dependency'.
Mar 22 01:24:36 localhost systemd[1]: dev-disk-by\x2duuid-b3bbf535\x2df6ea\x2d4a46\x2dbd46\x2d813a542993af.device: Job dev-disk-by\x2duuid-b3bbf535\x2df6ea\x2d4a46\x2dbd46\x2d813a542993af.device/start failed with result 'timeout'.
Mar 22 01:24:36 localhost systemd[1]: Reached target Preparation for Local File Systems.

I realised that this uuid was in my original config before I recreated the new disk configurations/hosts/orca/hardware-configuration.nix at 2a052ebff0492d1738d35b99a7ea0923fa4e68f9 · addy419/configurations · GitHub, but it makes no sense, since this is a fresh nixos install with a new LUKS partition. The file was modified before I ran nixos-install, so the original uuid shouldn’t be mentioned anywhere in my new config. The only mistake on my part would be that I did not delete the previous partitions, but formatted them with mkfs.fat, cryptsetup and mkfs.btrfs. But again, their uuids changed, so I don’t have a clue why systemd remembers the old ones.

Tried nix-collect-garbage -d and even deleting /boot and recreating it. The issue still persists.

Here’s my fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>

# Filesystems.
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 / btrfs x-initrd.mount,subvol=root,compress=zstd,noatime 0 0
/dev/disk/by-uuid/EB00-8E11 /boot vfat defaults 0 2
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 /home btrfs subvol=home,compress=zstd 0 0
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 /home/aditya/.local/share/steam btrfs subvol=steam,compress=zstd,noatime 0 0
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 /home/aditya/.local/virt btrfs subvol=virt,compress=zstd,noatime 0 0
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 /nix btrfs x-initrd.mount,subvol=nix,compress=zstd,noatime 0 0
/dev/disk/by-uuid/1328a0a5-759d-4e57-9f77-679bb5f92bd8 /swap btrfs subvol=swap,noatime 0 0

and

/dev/disk/by-uuid RO ➜ ll
total 0
lrwxrwxrwx 1 root root 10 Mar 22 16:57 1328a0a5-759d-4e57-9f77-679bb5f92bd8 -> ../../dm-0
lrwxrwxrwx 1 root root 10 Mar 22 16:59 31F52184144C58CF -> ../../sda1
lrwxrwxrwx 1 root root 15 Mar 22 16:59 8d24cbb7-ba15-49cf-a6ff-e58a7a3ee4e0 -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Mar 22 16:59 EB00-8E11 -> ../../nvme0n1p1

Similar issue faced by someone else Systemd how delete .device unit - #4 by dalto - Kernel, boot, graphics & hardware - EndeavourOS, but I am not sure if this is a good solution, since I have no idea how the service is created after a full reinstall of nixos.

Edit: I might have found the issue. I read on arch forums that this is a common behavior with stale efivars. I don’t have access to the affected machine for a few days, but will check back and confirm it here.

I found the issue, it was HibernateLocation efi var. using chattr -i on the efivar file and deleting it with rm fixed the issue.