Skip to content

Commit b36e876

Browse files
committedApr 1, 2025·
zfs: properly disable zfs-based swap
1 parent 212ff71 commit b36e876

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
 

‎disk-deactivate/disk-deactivate

+2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ set -efux -o pipefail
44
disk=$(realpath "$1")
55

66
lsblk -a -f >&2
7+
# since we currently cannot recursively deactivate swaps on zfs volumes, we need to deactivate all of them.
8+
lsblk --output-all --json | jq -r -f "$(dirname "$0")/zfs-swap-deactivate.jq" | bash -x
79
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
810
lsblk -a -f >&2
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def turnOffSwaps:
2+
if (.name | test("^zd[0-9]+$")) and .type == "disk" then
3+
"swapoff /dev/" + .name
4+
else
5+
[]
6+
end
7+
;
8+
9+
.blockdevices | map(turnOffSwaps) | flatten | join("\n")
10+

‎flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
7373
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
74+
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/zfs-swap-deactivate.jq}
7475
touch $out
7576
'';
7677

0 commit comments

Comments
 (0)
Please sign in to comment.