From a0e270b51bbe733f89f1d93a2fb898131004c27e Mon Sep 17 00:00:00 2001 From: Matheus Guilhermino Date: Thu, 30 Mar 2023 16:25:06 -0300 Subject: [PATCH] Add mpath support to wipedisk script The wipedisk script was not able to find the boot device when using multipath disks. This is due to the fact that multipath devices are not listed under /dev/disk/by-path/. To add support to multipath devices, the script should look for the boot device under /dev/disk/by-id/ as well. Test Plan PASS: Successfully run wipedisk on a AIO-SX with multipath PASS: Successfully run wipedisk on a AIO-SX w/o multipath Closes-bug: 2013391 Signed-off-by: Matheus Guilhermino Change-Id: I3af76cd44f22795784a9184daf75c66fc1b9874f --- mtce/src/scripts/wipedisk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mtce/src/scripts/wipedisk b/mtce/src/scripts/wipedisk index 7968b84e..fab193fc 100755 --- a/mtce/src/scripts/wipedisk +++ b/mtce/src/scripts/wipedisk @@ -66,7 +66,11 @@ declare WIPE_HDD= # Only wipe the boot device disks boot_disk_part=$(df --output=source /boot | tail -1) -boot_disk=$(readlink -f $(find -L /dev/disk/by-path/ -samefile $boot_disk_part | sed 's/-part[0-9]*'//)) +boot_disk_path=$(find -L /dev/disk/by-path/ -samefile ${boot_disk_part} | sed 's/-part[0-9]*'//) +if [ -z "${boot_disk_path}" ] ; then + boot_disk_path=$(find -L /dev/disk/by-id/ -samefile ${boot_disk_part} | grep wwn | sed 's/-part[0-9]*'//) +fi +boot_disk=$(readlink -f ${boot_disk_path}) if [ -z "$boot_disk" ] ; then echo "Boot disk not found. Failed to wipe disk." @@ -129,6 +133,14 @@ for dev in $WIPE_HDD ; do *"nvme"*) part=${dev}p${part_number} ;; + *"dm-"*) + for p in /dev/disk/by-id/wwn-*; do + if [ "${dev}" = "$(readlink -f ${p})" ]; then + part=${p}-part${part_number} + break + fi + done + ;; esac sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev) part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')