[sclug] How to find which /dev/xxx a usb device is on? (No UUID required)

Stuart Ward stuart.ward at bcs.org
Tue Jun 24 16:38:10 UTC 2008


If what you want to do is know the device name of a USB device I would
suggest you make a udev rule to map the the device name.

SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1",
SYMLINK+="usbdrive"

Where the product and vendor numbers match your device and then it
will create a link to the actual device
You can also create a RUN rule to perform some action on insertion if
you want. ie mount it

-- Stuart Ward M +44 7782325143


On Tue, Jun 24, 2008 at 3:17 PM, John Stumbles <sclug at yaph.org.uk> wrote:
> David Kerrawn wrote:
>>
>> /sys/block contains a list of block devices.
>> /sys/block/$drive/device is a symlink to the "actual device"
>> In this symlink there is the USB device info eg: 4-4 which ties in with
>> the
>> output from lsusb.
>
>> You should be able to work out the rest from there.
>
> You mean walk /sys/block/ to find which sdX/device symlink target matches
> the ID of the device I'm looking for (as in lsusb output)? I guess that's
> straightforward enough (more perl than bash for my skills). I just wondered
> if there was a simple way :-)
>
> --
> John Stumbles                                       http://yaph.org.uk
> :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:
>



More information about the Sclug mailing list