Skip to content

Commit 2db1d64

Browse files
dvaerumMic92
authored andcommitted
Added example for swap on zfs_volume
I could not find an example of how to enable swap on a `zfs_volume` but since I made it work I wanted to share it 😁
1 parent 6c1b834 commit 2db1d64

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

example/zfs-encrypted-root.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@
5656
options.mountpoint = "/nix";
5757
mountpoint = "/nix";
5858
};
59+
60+
# README MORE: https://wiki.archlinux.org/title/ZFS#Swap_volume
61+
"root/swap" = {
62+
type = "zfs_volume";
63+
size = "10M";
64+
content = {
65+
type = "swap";
66+
};
67+
options = {
68+
volblocksize = "4096";
69+
compression = "zle";
70+
logbias = "throughput";
71+
sync = "always";
72+
primarycache = "metadata";
73+
secondarycache = "none";
74+
"com.sun:auto-snapshot" = "false";
75+
};
76+
};
5977
};
6078
};
6179
};

tests/zfs-encrypted-root.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ diskoLib.testLib.makeDiskoTest {
1313
extraTestScript = ''
1414
machine.succeed("mountpoint /");
1515
machine.succeed("mountpoint /nix");
16+
machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0
1617
'';
1718
}

0 commit comments

Comments
 (0)