nix-community / disko

Declarative disk partitioning and formatting using nix [maintainers=@Lassulus @Enzime]
MIT License
1.7k stars 186 forks source link

Mounting the encrypted disko config takes to long - Disko config wrong or Mount config wrong? #620

Closed xerhaxs closed 5 months ago

xerhaxs commented 5 months ago

Hey everyone, I wrote a disko config and my mount config, but for some reason it takes an extremly long time to mount the partitions during boot.

The Disko config:

{ config, disks ? [ "/dev/nvme0n1" ], lib, pkgs, ... }:

    disko.devices = {
      disk = {
        vda = {
          name = "SYSTEM";
          type = "disk";
          device = builtins.elemAt disks 0;
          content = {
            type = "gpt";
            partitions = {
              ESP = {
                name = "BOOT";
                type = "EF00";
                size = "500M";
                content = {
                  type = "filesystem";
                  format = "vfat";
                  mountpoint = "/boot";
                };
              };
              luks = {
                name = "crypt";
                size = "100%";
                content = {
                  name = "crypt";
                  type = "luks";
                  extraOpenArgs = [ "--cipher aes-xts-plain64" "--key-size 512" "--hash sha512" ];
                  settings = {
                    keyFile = "/tmp/secret.key";
                    allowDiscards = true;
                  };
                  additionalKeyFiles = [ "/tmp/keyfile.key" ];
                  content = {
                    type = "lvm_pv";
                    vg = "crypt";
                  };
                };
              };
            };
          };
        };
      };
      lvm_vg = {
        crypt = {
          type = "lvm_vg";
          lvs = {
            root = {
              name = "root";
              size = "40%FREE";
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
              };
            };
            home = {
              name = "home";
              size = "100%FREE";
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/home";
              };
            };
          };
        };
      };
    };

My config to mount the drives and partitions:

    boot.initrd.luks.devices = {
      "crypt" = {
        device = "/dev/disk/by-partlabel/disk-SYSTEM-crypt";
        preLVM = true;
        #fallbackToPassword = true;
      };
    };

    fileSystems."/" = {
      device = "/dev/crypt/root";
      fsType = "ext4";
    };

    fileSystems."/boot" = {
      device = "/dev/disk/by-partlabel/disk-SYSTEM-BOOT";
      fsType = "vfat";
    };

    fileSystems."/home" = {
      device = "/dev/crypt/home";
      fsType = "ext4";
    };

Has someone an idea how to fix this?

xerhaxs commented 5 months ago

Solved! The mistake was that I enabled a hibernate device, but not specified one in disko. So the system search for a swap drive, but could not find one and so it took very long to boot.