yodaTux swapfile

This commit is contained in:
Daniel Langbein 2025-02-03 10:37:58 +01:00
parent 1416938571
commit d3468aa5e1
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
2 changed files with 21 additions and 5 deletions

View File

@ -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

View File

@ -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