diff --git a/README.md b/README.md index af82c9e..62140ff 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,19 @@ Use the corresponding branch: # TODO (!) ``` +## BTRFS Swap file + +* https://nixos.wiki/wiki/Btrfs#Swap_file +* https://wiki.archlinux.org/title/btrfs#Swap_file + +Summary: + +* Create subvolume `@swap` directly below top-level subvolume. +* Mount at `/swap` +* Create swapfile: `sudo btrfs filesystem mkswapfile --size 8g --uuid clear /swap/swapfile` +* Regenerate hardware-configuration: `sudo nixos-generate-config --dir yodaTab` +* Add `swapDevices = [ { device = "/swap/swapfile"; } ];` to hardware configuration and run `nixos-rebuild switch` (see above). + ## Automount Encrypted Drive * Generate and add keyfile to LUKS device diff --git a/yodaTab/hardware-configuration.nix b/yodaTab/hardware-configuration.nix index 9a387c0..05e62ac 100644 --- a/yodaTab/hardware-configuration.nix +++ b/yodaTab/hardware-configuration.nix @@ -35,7 +35,13 @@ boot.initrd.luks.devices."512gb".device = "/dev/disk/by-uuid/03d4ac28-2c81-463e-b615-fb623d40b6fa"; - swapDevices = [ ]; + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/f87e6b3c-12f2-4fda-92b3-06b07bdad58f"; + fsType = "btrfs"; + options = [ "subvol=@swap" ]; + }; + + swapDevices = [ { device = "/swap/swapfile"; } ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's