I'm trying to detect the USB version (USB 2.0/USB 3.0) from just the drive label.I know the USB version can be fetched from bcdUSB parameter in the output of lsusb -v or the Operating speed parameter in the output of lsusb -t (480M/5000M).And I know the drive label can be found from the output of lsblk, But I can't figure out a way to match those outputs to match USB version with the drive label.My backup option is to test speed of transfer for a file to detect USB version, but that's not very reliable.I was hoping for an easy and reliable way. Any guidance is really appreciated.
Find USB version from disk label on Unix
usb;lsusb
This is a system-specific thing, but presuming Linux (and not, say, BSD, etc.):If you have the device name (which lsblk gives you), then:$ udevadm info -a /dev/sdf1Udevadm info starts with the device specified by the devpath and thenwalks up the chain of parent devices. It prints for every devicefound, all possible attributes in the udev rules key format.A rule to match, can be composed by the attributes of the deviceand the attributes from one single parent device.  looking at device '/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host16/target16:0:0/16:0:0:0/block/sdf/sdf1':    KERNEL==sdf1  looking at parent device '/devices/pci0000:00/0000:00:1a.7/usb1/1-2':    KERNELS==1-2    SUBSYSTEMS==usb    DRIVERS==usb    ATTRS{speed}==480I suspect 'speed' is what you're looking for. If not, there is also busnum and devnum there, which match the bus:device given by lsusb.This also gives you a clue of how to do it by hand: you look in /sys. You can find where to start by readlink -f /sys/block/sdf which tells me /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host16/target16:0:0/16:0:0:0/block/sdf. You can then strip off trailing directories until you get back up to the USB device. Then speed, busnum, devnum, etc. are just files you can read.