0

I am running Debian/Linux, and I would like to know what low level tools are available to print detailed information about a USB key (eg. USB 1.0 vs USB 2.0…). Neither dmesg, nor lsusb have proved to be useful so far.

I am interested in the key itself, not the connector as in here. For instance I'd like to compare two USB keys where the plastic is white.

malat
  • 1,374

2 Answers2

2

Dig into /sys. Start with /sys/bus/usb/devices/ or /sys/class/block/sdX/ (where sdX corresponds to your USB key). Read files.

This is how to get some information on USB port (I have no USB key at the moment to give better example):

$ cat /sys/bus/usb/devices/usb1/version
 2.00

More about /sys. There are tools that give information in a fancier way. Still, one may be surprised what can be found in /sys.

1

The proper way to query a device properties, nowadays, is via udevadm:

# udevadm info --query=all --name=/dev/sdb
 P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/host5/target5:0:0/5:0:0:0/block/sdb
 N: sdb
 S: disk/by-id/usb-Verbatim_STORE_N_GO_TTFEAZVTZPCNBF3Q-0:0
 S: disk/by-path/pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0
 E: DEVLINKS=/dev/disk/by-id/usb-Verbatim_STORE_N_GO_TTFEAZVTZPCNBF3Q-0:0 /dev/disk/by-path/pci-0000:00:14.0-  usb-0:2:1.0-scsi-0:0:0:0
 E: DEVNAME=/dev/sdb
 E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/host5/target5:0:0/5:0:0:0/block/sdb
 E: DEVTYPE=disk
 E: ID_BUS=usb
 E: ID_INSTANCE=0:0
 E: ID_MODEL=STORE_N_GO
 E: ID_MODEL_ENC=STORE\x20N\x20GO\x20\x20\x20\x20\x20\x20
 E: ID_MODEL_ID=0302
 E: ID_PART_TABLE_TYPE=dos
 E: ID_PATH=pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0
 E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_0-scsi-0_0_0_0
 E: ID_REVISION=1100
 E: ID_SERIAL=Verbatim_STORE_N_GO_TTFEAZVTZPCNBF3Q-0:0
 E: ID_SERIAL_SHORT=TTFEAZVTZPCNBF3Q
 E: ID_TYPE=disk
 E: ID_USB_DRIVER=usb-storage
 E: ID_USB_INTERFACES=:080650:
 E: ID_USB_INTERFACE_NUM=00
 E: ID_VENDOR=Verbatim
 E: ID_VENDOR_ENC=Verbatim
 E: ID_VENDOR_ID=18a5
 E: MAJOR=8
 E: MINOR=16
 E: SUBSYSTEM=block
 E: USEC_INITIALIZED=503624797

Different alternatives:

  1. If you just want to query sysfs for the device path (from /sys !!) of device /dev/sdb, use:

    # udevadm info --query=path --name=/dev/sdb
      /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/host5/target5:0:0/5:0:0:0/block/sdb
    
  2. If you want to query the symbolic link pointing to /dev/sdb,

    # udevadm info --query=symlink --name=/dev/sdb
      disk/by-id/usb-Verbatim_STORE_N_GO_TTFEAZVTZPCNBF3Q-0:0 disk/by-path/pci-0000:00:14.0-usb-0:2:1.0-scsi-0:0:0:0
    
  3. If you only want the properties of the disk,

    udevadm info --query=property --name=/dev/sdb
    
  4. If you want the properties of the device, and of its parent devices,

     udevadm info --attribute-walk --name=/dev/sdb
    
MariusMatutiae
  • 48,517
  • 12
  • 86
  • 136