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 <matheus.machadoguilhermino@windriver.com>
Change-Id: I3af76cd44f22795784a9184daf75c66fc1b9874f
This commit is contained in:
Matheus Guilhermino 2023-03-30 16:25:06 -03:00
parent 5bd181cdcf
commit a0e270b51b
1 changed files with 13 additions and 1 deletions

View File

@ -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;}')