From be305848c682f221835c820288264bbf2ccf523c Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 10 Jan 2024 13:24:53 +0100 Subject: [PATCH] umount md device before stopping the raid --- disk-deactivate/disk-deactivate.jq | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/disk-deactivate/disk-deactivate.jq b/disk-deactivate/disk-deactivate.jq index 16d72b7..632bf8d 100644 --- a/disk-deactivate/disk-deactivate.jq +++ b/disk-deactivate/disk-deactivate.jq @@ -27,7 +27,8 @@ def deactivate: if .type == "disk" then [ # If this disk is a member of raid, stop that raid - "lsblk \(.path) -l -p -o type,name | awk 'match($1,\"raid.*\") {print $2}' | xargs -r mdadm --stop", + "md_dev=$(lsblk \(.path) -l -p -o type,name | awk 'match($1,\"raid.*\") {print $2}')", + "if [[ -n \"${md_dev}\" ]]; then umount \"$md_dev\"; mdadm --stop \"$md_dev\"; fi", # Remove all file-systems and other magic strings "wipefs --all -f \(.path)", # Remove the MBR bootstrap code