Skip to content

Commit

Permalink
disk-deactivate: also clear zpool labels
Browse files Browse the repository at this point in the history
this helps to avoid ghost pools.
  • Loading branch information
Mic92 committed Sep 3, 2024
1 parent c789d11 commit 736c815
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions disk-deactivate/disk-deactivate.jq
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# since lsblk lacks zfs support, we have to do it this way
def remove:
if .fstype == "zfs_member" then
"if type zpool >/dev/null; then zpool destroy -f \(.label); fi"
"if type zpool >/dev/null; then zpool destroy -f \(.label); zpool labelclear -f \(.label); fi"
elif .fstype == "LVM2_member" then
[
"vg=$(pvs \(.path) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')",
Expand All @@ -14,8 +14,8 @@ def remove:
# maybe its zfs
[
# the next line has some horrible escaping
"zpool=$(if type zdb >/dev/null; then zdb -l \(.path) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p') else echo ""; fi",
"if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; fi",
"zpool=$(if type zdb >/dev/null; then zdb -l \(.path) | sed -nr $'s/ +name: \\'(.*)\\'/\\\\1/p'; fi)",
"if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; zpool labelclear -f \"$zpool\"; fi",
"unset zpool"
]
else
Expand Down

0 comments on commit 736c815

Please sign in to comment.