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
117
117
echo " $wwn " >> " $md_file "
118
118
done
119
119
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
122
122
fi
123
123
sort --unique -o " $md_file " " $md_file "
124
124
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
19
19
20
20
function usage() {
21
21
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."
23
23
echo " ATTENTION! THIS DELETES ALL DATA ON THE GIVEN DISK!"
24
24
echo " Existing WWNs:"
25
25
lsblk -oNAME,WWN | grep -vi loop || true
@@ -32,6 +32,14 @@ if [ $# -eq 0 ]; then
32
32
exit 3
33
33
fi
34
34
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
+
35
43
# Iterate over all input arguments
36
44
for wwn in " $@ " ; do
37
45
if ! lsblk -l -oWWN | grep -qFx " ${wwn} " ; then
@@ -45,6 +53,19 @@ for wwn in "$@"; do
45
53
echo " Failed to find device for WWN $wwn "
46
54
exit 3
47
55
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 )"
49
70
wipefs -af " /dev/$device "
50
71
done
You can’t perform that action at this time.
0 commit comments