disk-deactivate: also clear zpool labels

this helps to avoid ghost pools.
This commit is contained in:
Jörg Thalheim 2024-09-03 15:44:26 +02:00
parent c789d113c6
commit 736c8150b9

View file

@ -1,7 +1,7 @@
# since lsblk lacks zfs support, we have to do it this way # since lsblk lacks zfs support, we have to do it this way
def remove: def remove:
if .fstype == "zfs_member" then 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 elif .fstype == "LVM2_member" then
[ [
"vg=$(pvs \(.path) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')", "vg=$(pvs \(.path) --noheadings --options vg_name | grep -o '[a-zA-Z0-9-]*')",
@ -14,8 +14,8 @@ def remove:
# maybe its zfs # maybe its zfs
[ [
# the next line has some horrible escaping # 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", "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\"; fi", "if [[ -n \"${zpool}\" ]]; then zpool destroy -f \"$zpool\"; zpool labelclear -f \"$zpool\"; fi",
"unset zpool" "unset zpool"
] ]
else else