Hi On 10.02.21 19:59, Thomas Lange wrote:
I think we want to match all real disks which can be identified by a name, model, serial number. Maybe also virtualized disks which have such an entry at by-id.
given that the `ata` bits came from my initial script and the fact that we mostly have SATA drives in our machines, I feel a bit of guilty ;-)
Would something like a "choice-priority" function fly instead?I assume udevadm would return any of the valid device links and by-path is always set, thus:
get_stable_devname() {
_DEV="$1"
# prefer SCSI over ATA over WWN over path
RET=""
for i in $(udevadm info -r --query=symlink "$_DEV")
do
if [[ "$i" =~ /by-id/scsi && -z "$RET" ]]
then
RET="$i"
elif [[ "$i" =~ /by-id/ata && -z "$RET" ]]
then
RET="$i"
elif [[ "$i" =~ /by-id/wwn && -z "$RET" ]]
then
RET="$i"
elif [[ "$i" =~ /by-path/ && -z "$RET" ]]
then
RET="$i"
fi
done
echo "$RET"
}
get_stable_devname /dev/sda
(or am I missing the point)?
Cheers
Carsten
--
Dr. Carsten Aulbert, Max Planck Institute for Gravitational Physics,
Callinstraße 38, 30167 Hannover, Germany, Phone +49 511 762 17185
smime.p7s
Description: S/MIME Cryptographic Signature
