3 # input eg: /dev/sda1 or /dev/sda
4 # output: /dev/disk/by-id/model+serial, or if no link exists, the same as input
8 # devices are identified by model+serial num
9 # and for ssd/hdd: wwn, and for nvme: eui.
10 # model+serial gives me more info, so use that.
12 for id
in /dev
/disk
/by-id
/!(nvme-eui
*|wwn
*); do
13 [[ -e $id ]] ||
break # if we matched nothing
14 if [[ $
(readlink
-f $id) == "$short_dev" ]]; then
19 # a vm may not have a by-id link.
20 printf '%s\n' "$short_dev"