File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
pkg/services/baremetal/client/ssh Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,8 @@ for mdraid in /dev/md?*; do
117117 echo " $wwn " >> " $md_file "
118118 done
119119 if [ ! -s " $md_file " ]; then
120- echo " failed to find devices of $mdraid "
121- exit 3
120+ echo " mdraid without disks: $mdraid (skipping it) "
121+ continue
122122 fi
123123 sort --unique -o " $md_file " " $md_file "
124124 if cmp --silent " $md_file " " $wwn_file " ; then
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ set -Eeuo pipefail
1919
2020function usage() {
2121 echo " $0 wwn1 [wwn2 ...]"
22- echo " Wipe all filesystem, raid or partition-table signaturesfrom the specified disks."
22+ echo " Wipe all filesystem, raid or partition-table signatures from the specified disks."
2323 echo " ATTENTION! THIS DELETES ALL DATA ON THE GIVEN DISK!"
2424 echo " Existing WWNs:"
2525 lsblk -oNAME,WWN | grep -vi loop || true
@@ -32,6 +32,14 @@ if [ $# -eq 0 ]; then
3232 exit 3
3333fi
3434
35+ # Show usage, if any argument starts with a dash.
36+ for arg in " $@ " ; do
37+ if [[ " $arg " == -* ]]; then
38+ usage
39+ exit 3
40+ fi
41+ done
42+
3543# Iterate over all input arguments
3644for wwn in " $@ " ; do
3745 if ! lsblk -l -oWWN | grep -qFx " ${wwn} " ; then
@@ -45,6 +53,19 @@ for wwn in "$@"; do
4553 echo " Failed to find device for WWN $wwn "
4654 exit 3
4755 fi
48- echo " INFO: Calling wipfs for $wwn (/dev/$device )"
56+
57+ lsblk --list --noheadings " /dev/$device " -o NAME | { grep -P ' ^md' || true ; } | sort -u |
58+ while read -r md; do
59+ echo " INFO: Stopping mdraid $md for $wwn (/dev/$device )"
60+ mdadm --stop " $md "
61+ sleep 0.1
62+ if grep -qP " ^$md \s*:" /proc/mdstat; then
63+ echo " INFO: $md is still in /proc/mdstat, attempting to remove it."
64+ mdadm --remove " $md "
65+ sleep 0.1
66+ fi
67+ done
68+
69+ echo " INFO: Calling wipefs for $wwn (/dev/$device )"
4970 wipefs -af " /dev/$device "
5071done
You can’t perform that action at this time.
0 commit comments