disko icon indicating copy to clipboard operation
disko copied to clipboard

encrypted swap and hibernation

Open ed-aka-yaboi opened this issue 1 year ago • 1 comments

I have the following template running, and the swap is being picked up by htop. However, running systemctl hibernate results in the following error:

✦ ❯ systemctl hibernate
Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems
{ config, ... }:
let
  cfg = config.services.disko;
in
{
  disko.devices = {
    disk = {
      "${cfg.disk}" = {
        type = "disk";
        device = "/dev/${cfg.disk}";
        content = {
          type = "gpt";
          partitions = {
            boot = {
              name = "boot";
              size = "1M";
              type = "EF02";
            };
            esp = {
              size = "500M";
              type = "EF00";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot/efi";
              };
            };
            luks = {
              end = "-32G";
              content = {
                type = "luks";
                name = "crypted";
                settings.allowDiscards = true;
                passwordFile = "/tmp/secret.key";
                content = {
                  type = "filesystem";
                  format = "ext4";
                  mountpoint = "/";
                };
              };
            };
            encryptedSwap = {
              size = "100%";
              content = {
                type = "swap";
                randomEncryption = true;
                resumeDevice = true;
              };
            };
          };
        };
      };
    };
  };
}

Thanks for the help!

ed-aka-yaboi avatar Apr 18 '24 11:04 ed-aka-yaboi

The issue is, that randomEncryption and resumeDevice do not work together. The best bet would be something like this for you: https://unix.stackexchange.com/questions/529047/is-there-a-way-to-have-hibernate-and-encrypted-swap-on-nixos

xerhaxs avatar May 04 '24 11:05 xerhaxs

Yes. The encrypted swap option uses a random key in NixOS. This is nothing that Disko can fix.

Mic92 avatar May 15 '24 07:05 Mic92