From d3468aa5e135dfa17592b1ad7463e1ceebb74b33 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Mon, 3 Feb 2025 10:37:58 +0100 Subject: [PATCH] yodaTux swapfile --- README.md | 17 +++++++++++++---- hosts/yodaTux/hardware-configuration.nix | 9 ++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 628b0d5..f48f44e 100644 --- a/README.md +++ b/README.md @@ -306,10 +306,19 @@ Filtering: 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 hosts/$(hostname)` -* Add `swapDevices = [ { device = "/swap/swapfile"; } ];` to hardware configuration and run `nixos-rebuild switch` (see above). + * `sudo mkdir -p /mnt/ssd` + * `sudo mount /dev/disk/by-uuid/01f67928-9b35-48b2-aaa6-c58ff6c440a8 /mnt/ssd` + * `sudo btrfs subvolume create /mnt/ssd/@swap` + * `sudo umount /mnt/ssd` +* Mount subvolume at `/swap`. + * `sudo mkdir /swap` + * `sudo mount -o subvol=@swap /dev/disk/by-uuid/01f67928-9b35-48b2-aaa6-c58ff6c440a8 /swap` +* Create swapfile `/swap/swapfile`. + * `sudo btrfs filesystem mkswapfile --size 8g --uuid clear /swap/swapfile` +* Regenerate hardware-configuration. This will add `fileSystems."/swap"` to it. + * `sudo nixos-generate-config --dir hosts/$(hostname)` +* Add `swapDevices = [ { device = "/swap/swapfile"; } ];` to hardware-configuration. +* Apply your new NixOS config. This will activate the swapfile. ## BTRFS CoW diff --git a/hosts/yodaTux/hardware-configuration.nix b/hosts/yodaTux/hardware-configuration.nix index 6bd36a1..c3e6f47 100644 --- a/hosts/yodaTux/hardware-configuration.nix +++ b/hosts/yodaTux/hardware-configuration.nix @@ -24,9 +24,16 @@ fileSystems."/boot" = { device = "/dev/disk/by-uuid/4840-0BFE"; fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; }; - swapDevices = [ ]; + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/01f67928-9b35-48b2-aaa6-c58ff6c440a8"; + 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