linuxusbusb-drive

Find /dev entry with VID/PID of USB device


I'd like to make a program that will detect which /dev/sd* entry is linked to a known USB VID/PID pair.

Do you know how I can get the VID/PID of a USB stick that would appear as /dev/sd*?


Solution

  • you can use udevadm for this

    in the output of udevadm info -q property -n /dev/sd* the VID is in the ID_VENDOR_ID field and the PID is in the ID_MODEL_ID field

    you can extract this using grep / sed...