Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 07-17-2011, 09:58 AM   #1
LQ Newbie
Registered: Feb 2010
Posts: 3

Rep: Reputation: 0
How do I find the /dev/sd device currently assigned to a physical flash drive port?

I have (at least 4) native USB ports that contain flash drives. I know that the /dev/sd[abcd] devices are created in the order they were inserted, but say you have all four plugged in at boot time, or further, they can be plugged and unplugged in real time. At times, /dev/sdf, /dev/sdg, etc. are created as well. I'm ignoring external hubs for now.

I need to know which drive is plugged into the "top port on the front panel", etc, by physical location. From dmesg I can check right after booting and get the physical assignment of a PCI device, say, PCI 0000:00:10.3, as being assigned to the EHCI usb bus. From /proc/bus/usb/devices, and the "T:" field, I have learned that the physical connectors I'm interested are known as USB Bus 1, Port=00, Port=01, Port=04, and Port=05.

From lsusb I can see all sorts of information from the USB point of view, but with no /dev/sd references.

From /proc/scsi/scsi, I can see what scsi devices have been created, with a count consistent with the number of flash drives plugged in, but no USB data.

So, I can get lots of information from the USB storage point of view, and lots of information from the SCSI point of view, but nowhere can I find how to correlate them. In other words, if I want to mount the drive plugged into a given physical slot, how can I find the /dev/sd device I need to mount? udev isn't really interesting here, because I'm just looking for the information that udev would use to answer the same question.

I've done some heaving exploring in the /sys and /proc filesystems and have not yet found where the USB and SCSI worlds intersect.

The closest I have found is (where "Port" is the physical port number from above):

P=$(expr $Port + 1)
ls -d /sys/devices/pci0000:00/0000:00:10.3/usb1/1-${P}/*/\


This seems to have some mapping to the physical port and references a "/dev/sd[a-z]" value, but I don't know how reliable it might be, nor do I know if my having to increment that physical port by 1 is meaningful. Anyone have a simpler approach?

So, my goal becomes
mount /dev/<sd that was created for the top slot> /mnt/top
mount /dev/<sd that was created for the bottom slot> /mnt/bottom etc.

Anyone been here?


Old 07-18-2011, 03:49 PM   #2
Registered: Mar 2008
Posts: 17,944

Rep: Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676Reputation: 2676
Mount with no options just mount command is the command to view that I'd think.

Use uuid instead maybe.
Old 07-18-2011, 09:33 PM   #3
LQ Newbie
Registered: Feb 2010
Posts: 3

Original Poster
Rep: Reputation: 0
mount will tell me what devices are mounted, but not where physically each is mounted. (i.e., which one is mounted in the left side of the computer and which is in the right).

Thanks, though.
Old 01-17-2012, 11:33 AM   #4
LQ Newbie
Registered: Jan 2012
Posts: 1

Rep: Reputation: Disabled
Not sure if it is still relevant ...

Check out the following example:

admin@ER1108006398:~$ cat /proc/partitions
major minor #blocks name

8 0 488386584 sda
8 1 19530226 sda1
8 2 9765625 sda2
8 3 459089692 sda3
8 16 2007040 sdb
8 17 2001053 sdb1
8 32 15605504 sdc
8 33 15605244 sdc1
8 48 1423360 sdd
8 49 1423352 sdd1
admin@ER1108006398:~$ ls /proc/scsi/usb-storage/
16 17 2
admin@ER1108006398:~$ cat /proc/scsi/usb-storage/16
Host scsi16: usb-storage
Vendor: Apple Inc.
Product: iPod
Serial Number: 000A27002033BCE9
Protocol: Transparent SCSI
Transport: Bulk
admin@ER1108006398:~$ cat /proc/scsi/usb-storage/17
Host scsi17: usb-storage
Vendor: Amazon
Product: Amazon Kindle
Serial Number: B00E150114323KLX
Protocol: Transparent SCSI
Transport: Bulk
admin@ER1108006398:~$ cat /proc/scsi/usb-storage/2
Host scsi2: usb-storage
Vendor: Transcend
Product: TS2GUFM-H
Serial Number: TS20100712000008
Protocol: Transparent SCSI
Transport: Bulk
Old 01-18-2012, 09:35 AM   #5
Senior Member
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,042

Rep: Reputation: 54
I think this could give some light to your problem:

It basically tells you to assign every USB with their own SN to a specific /dev/sd device. Later you can define mount point in /etc/fstab


device, mount, physical, scsi, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
what command will identify which dev file my device was assigned kevmcool Linux - Newbie 3 02-02-2010 06:54 AM
Which hdd drive is assigned to what device? jernejk Linux - Hardware 1 05-27-2009 02:20 PM
Is there an easier to way to find out which /dev/ my flash drive is connected to... trist007 Linux - Newbie 20 04-09-2009 07:01 PM
using flash drive changes device /dev/sr0 to /dev/sr1 for mapping to /dev/pktcdvd/0? lugoteehalt Linux - Software 3 10-24-2007 10:27 AM
Help mounting USB flash drive ... When plugged in I dont have /dev/sda1 device ... ebenh Ubuntu 2 09-17-2006 09:55 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration