; , DMI root ( , ):
dmesg | grep -i dmi: | cut -d ":" -f 2-
"" dmidecode :
sudo chmod +s /usr/sbin/dmidecode
, :
dmidecode -s system-serial-number
" " " " " ". , , , Debian , .
, , ; :
mount | grep "on / type" | awk '{print $1}'
, ( /dev/sda7), :
find /dev/disk/by-id/ -lname "*sda" ! -name "wwn*"
Thus, a complete command to search for a unique identifier on your systemβs hard drive might be:
find /dev/disk/by-id/ -lname "*'mount | grep " / " | awk '{print $1}' | cut -b 6-8'" ! -name "wwn*" -printf "%f\n"
I hope this can fit your needs or someone else here. The cut -b 6-8 command may not be portable because I assume the block device names are three characters long; moreover, the path / dev / disk / by-id / path is filled only by managed UDEV systems, and not all Linux distributions use it, but I guarantee that the first ones will work in Ubuntu.
source
share