How to increase performance of LUKS SSDs?

When using encrypted SSDs it is recommended to add the arguments discard,no-write-workqueue,no-read-workqueue to the entry.

This is what I added to my hardware configuration.

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/aa228831-ad64-488c-9f53-d3ea2f5db00c";
      fsType = "btrfs";
      options = [ "acl,discard,no-read-workqueue,no-write-workqueue" ];
    };

But it returns btrfs: unknown parameter no-read-workqueue and fails to boot.

What is the issue here? Am I adding it at the wrong place? It should be added to /etc/crypttab

Reference:

I solved it like this:

  boot.initrd.luks.devices."NIXCRYPT".device = "/dev/disk/by-uuid/f5518dc7-cad7-4bd8-b1af-83f440a2a62f";
  boot.initrd.luks.devices."NIXCRYPT".bypassWorkqueues = true; # Only recommended for NVME SSDs
  boot.initrd.luks.devices."NIXCRYPT".allowDiscards = true; # Important for SSD lifespan if no hardcore security requirement
  
  fileSystems."/" = {
    # Use of /dev/mapper to prevent the timeout of 90 seconds when entering the lukse passphrase.
    device = "/dev/mapper/NIXCRYPT";
    fsType = "ext4";
  };
1 Like

It’s because you added them to fileSystems, which is effectively equivalent to fstab, not crypttab. @DocBrown101 has it right; though it’s worth noting that the reason these are nixos options and not an arbitrary list of crypttab options is because nixos’s scripted initrd doesn’t use crypttab; it just implements features like these manually. But boot.initrd.systemd.enable enables the systemd initrd which does use crypttab and those options will be converted into boot.initrd.luks.devices.<name>.crypttabExtraOpts options which is just an arbitrary list of crypttab options. (Also the 90 second timeout that @DocBrown101’s code refers to in the comment only happens with systemd initrd)

2 Likes