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 wwn. model+serial gives me more info, so use that.
11 for id
in /dev
/disk
/by-id
/!(wwn
*); do
12 [[ -e $id ]] ||
break # if we matched nothing
13 if [[ $
(readlink
-f $id) == "$short_dev" ]]; then
18 # a vm may not have a by-id link.
19 printf '%s\n' "$short_dev"