* How to find SCSI device to USB device association.
@ 2011-05-09 19:12 StephanT
2011-05-09 19:41 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: StephanT @ 2011-05-09 19:12 UTC (permalink / raw)
To: kernelnewbies
Hi all,
System description: disk-less ARM, 32M, Linux 2.6.30, 4 USB ports.
I plug in two USB flash sticks and I get:
% df -h
/dev/sda1 3.7G 32.1M 3.5G 1% /media/sda1
/dev/sdb1 7.4G 32.1M 7.0G 0% /media/sdb1
The sysfs shows:
% ls /sys/bus/scsi/devices/
25:0:0:0 26:0:0:0
(25 being the sda1 and 26 sdb1)
% ls /sys/bus/usb/devices/
1-0:1.0 1-1 1-1.1 1-1.1:1.0 1-1.4 1-1.4:1.0 1-1:1.0
usb1
and:
% ls -l /sys/devices/dw_otg/usb1/1-1
drwxr-xr-x 4 root root 0 Jan 1 14:10 1-1.1
drwxr-xr-x 4 root root 0 Jan 1 14:18 1-1.4
...
>From all this information: how can I find out the association USB
device number(1|4) to SCSI device (sda1|sdb1)
Thanks for your help,
Stephan.
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to find SCSI device to USB device association.
2011-05-09 19:12 How to find SCSI device to USB device association StephanT
@ 2011-05-09 19:41 ` Greg KH
2011-05-09 21:07 ` StephanT
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2011-05-09 19:41 UTC (permalink / raw)
To: kernelnewbies
On Mon, May 09, 2011 at 12:12:15PM -0700, StephanT wrote:
> Hi all,
>
> System description: disk-less ARM, 32M, Linux 2.6.30, 4 USB ports.
>
> I plug in two USB flash sticks and I get:
>
> % df -h
> /dev/sda1 3.7G 32.1M 3.5G 1% /media/sda1
> /dev/sdb1 7.4G 32.1M 7.0G 0% /media/sdb1
>
> The sysfs shows:
>
> % ls /sys/bus/scsi/devices/
> 25:0:0:0 26:0:0:0
>
> (25 being the sda1 and 26 sdb1)
>
> % ls /sys/bus/usb/devices/
> 1-0:1.0 1-1 1-1.1 1-1.1:1.0 1-1.4 1-1.4:1.0 1-1:1.0
> usb1
>
> and:
>
> % ls -l /sys/devices/dw_otg/usb1/1-1
>
> drwxr-xr-x 4 root root 0 Jan 1 14:10 1-1.1
> drwxr-xr-x 4 root root 0 Jan 1 14:18 1-1.4
> ...
>
> From all this information: how can I find out the association USB
> device number(1|4) to SCSI device (sda1|sdb1)
Why would you want such a mapping? It's not stable, changes every time,
and means nothing.
On the other hand, you can do this, look in the sysfs tree for the block
device, it will point you to the usb device from there.
Hope this helps,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to find SCSI device to USB device association.
2011-05-09 19:41 ` Greg KH
@ 2011-05-09 21:07 ` StephanT
2011-05-09 21:59 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: StephanT @ 2011-05-09 21:07 UTC (permalink / raw)
To: kernelnewbies
> Why would you want such a mapping? It's not stable, changes every time,
> and means nothing.
Well, because it is a customer/marketing request. And they have _always_
the last word :)
The system I'm working now is an embedded box having four USB ports. Each
port is labeled on the box USB1, USB2,... and the user expects to find the
files
on the stick plugged in USB1 on /media/usb1 folder. You can see my problem.
It happens the USB port labeled USB1 on the box has the port number 4. The
USB2 is the #3 and so on. The solution I was thinking of is to add a rule to the
UDEV USB section invoking a script which will create a logical link
"/media/usbx"
depending of the USB port# attached to the newly created "sda_". This link
is created every time the device is mounted and removed on umount.
Maybe you can suggest something simpler.
> Hope this helps,
Sure it helps. Thanks!
/st
^ permalink raw reply [flat|nested] 4+ messages in thread
* How to find SCSI device to USB device association.
2011-05-09 21:07 ` StephanT
@ 2011-05-09 21:59 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-05-09 21:59 UTC (permalink / raw)
To: kernelnewbies
On Mon, May 09, 2011 at 02:07:57PM -0700, StephanT wrote:
>
>
> > Why would you want such a mapping? It's not stable, changes every time,
> > and means nothing.
>
> Well, because it is a customer/marketing request. And they have _always_
> the last word :)
Even if it is an incorrect one, {sigh}.
> The system I'm working now is an embedded box having four USB ports. Each
> port is labeled on the box USB1, USB2,... and the user expects to find the
> files
> on the stick plugged in USB1 on /media/usb1 folder. You can see my problem.
Yes, that's not a nice one.
The _only_ way you are going to resolve this is to look at the USB path
id of the device. It will show you which port the device is plugged
into, and you are going to have to go off of that.
But watch out, you need to ignore USB bus and device ordering issues, as
they will change randomly.
> It happens the USB port labeled USB1 on the box has the port number 4. The
> USB2 is the #3 and so on. The solution I was thinking of is to add a rule to the
> UDEV USB section invoking a script which will create a logical link
> "/media/usbx"
> depending of the USB port# attached to the newly created "sda_". This link
> is created every time the device is mounted and removed on umount.
>
> Maybe you can suggest something simpler.
Look at /dev/disk/by-path/ the links are already set up for you there
that you can use.
good luck,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-09 21:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 19:12 How to find SCSI device to USB device association StephanT
2011-05-09 19:41 ` Greg KH
2011-05-09 21:07 ` StephanT
2011-05-09 21:59 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).