zfs: properly disable zfs-based swap
This commit is contained in:

committed by
Jörg Thalheim

parent
212ff71553
commit
b36e87600d
@@ -4,5 +4,7 @@ set -efux -o pipefail
|
|||||||
disk=$(realpath "$1")
|
disk=$(realpath "$1")
|
||||||
|
|
||||||
lsblk -a -f >&2
|
lsblk -a -f >&2
|
||||||
|
# since we currently cannot recursively deactivate swaps on zfs volumes, we need to deactivate all of them.
|
||||||
|
lsblk --output-all --json | jq -r -f "$(dirname "$0")/zfs-swap-deactivate.jq" | bash -x
|
||||||
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
|
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq" | bash -x
|
||||||
lsblk -a -f >&2
|
lsblk -a -f >&2
|
||||||
|
10
disk-deactivate/zfs-swap-deactivate.jq
Normal file
10
disk-deactivate/zfs-swap-deactivate.jq
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
def turnOffSwaps:
|
||||||
|
if (.name | test("^zd[0-9]+$")) and .type == "disk" then
|
||||||
|
"swapoff /dev/" + .name
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
;
|
||||||
|
|
||||||
|
.blockdevices | map(turnOffSwaps) | flatten | join("\n")
|
||||||
|
|
@@ -71,6 +71,7 @@
|
|||||||
|
|
||||||
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
|
checkJqSyntax = pkgs.runCommand "check-jq-syntax" { nativeBuildInputs = [ pkgs.jq ]; } ''
|
||||||
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
|
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/disk-deactivate.jq} --arg disk_to_clear foo
|
||||||
|
echo '{ "blockdevices" : [] }' | jq -r -f ${./disk-deactivate/zfs-swap-deactivate.jq}
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user