From 2db1d64fc084b1d15e3871dffc02c62a94ed6ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20V=C3=A6rum?= <6872940+dvaerum@users.noreply.github.com> Date: Mon, 10 Mar 2025 19:23:56 +0100 Subject: [PATCH] Added example for swap on `zfs_volume` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 😁 --- example/zfs-encrypted-root.nix | 18 ++++++++++++++++++ tests/zfs-encrypted-root.nix | 1 + 2 files changed, 19 insertions(+) diff --git a/example/zfs-encrypted-root.nix b/example/zfs-encrypted-root.nix index cb60a70..36b611f 100644 --- a/example/zfs-encrypted-root.nix +++ b/example/zfs-encrypted-root.nix @@ -56,6 +56,24 @@ options.mountpoint = "/nix"; mountpoint = "/nix"; }; + + # README MORE: https://wiki.archlinux.org/title/ZFS#Swap_volume + "root/swap" = { + type = "zfs_volume"; + size = "10M"; + content = { + type = "swap"; + }; + options = { + volblocksize = "4096"; + compression = "zle"; + logbias = "throughput"; + sync = "always"; + primarycache = "metadata"; + secondarycache = "none"; + "com.sun:auto-snapshot" = "false"; + }; + }; }; }; }; diff --git a/tests/zfs-encrypted-root.nix b/tests/zfs-encrypted-root.nix index 113625b..a196d06 100644 --- a/tests/zfs-encrypted-root.nix +++ b/tests/zfs-encrypted-root.nix @@ -13,5 +13,6 @@ diskoLib.testLib.makeDiskoTest { extraTestScript = '' machine.succeed("mountpoint /"); machine.succeed("mountpoint /nix"); + machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0 ''; }