LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
Search this Thread
Old 08-06-2007, 04:03 AM   #1
jjamesis
LQ Newbie
 
Registered: Nov 2006
Posts: 12

Rep: Reputation: 0
udevinfo - how do I uniquely identify the port a usb is on


Hope you can help me with this problem

I actually wrote a udev rule to give an external usb hard drive a persistent name and worked. The rule was
BUS=="usb", SYSFS{serial}=="01B70D2D01E9", NAME="usb_1".

What i would like to know is map to a device by the physical usb port is plugged into. I tried to used udevinfo to find this out but don't know which SYSFS key to use. Could anyone helpme identify which SYSFS key uniquely identifies the physical usb slot a usb device is plugged into.


I'am running Fedora 5 with a kernel 2.6.20-1.2320.fc5.

The output I got from udev is

***************************************************************************
udevinfo -a -p /sys/block/sdb/

udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.

looking at device '/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
SYSFS{stat}==" 43 38 642 6760 2 0 16 1 0 6754 6761"
SYSFS{size}=="321672960"
SYSFS{removable}=="0"
SYSFS{range}=="16"
SYSFS{dev}=="8:16"

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7/7-4/7-4:1.0/host3/target3:0:0/3:0:0:0':
ID=="3:0:0:0"
BUS=="scsi"
DRIVER=="sd"
SYSFS{ioerr_cnt}=="0x0"
SYSFS{iodone_cnt}=="0x34"
SYSFS{iorequest_cnt}=="0x34"
SYSFS{iocounterbits}=="32"
SYSFS{timeout}=="30"
SYSFS{state}=="running"
SYSFS{rev}=="V43O"
SYSFS{model}=="6DLAT80 "
SYSFS{vendor}=="HDT72251"
SYSFS{scsi_level}=="3"
SYSFS{type}=="0"
SYSFS{queue_type}=="none"
SYSFS{queue_depth}=="1"
SYSFS{device_blocked}=="0"
SYSFS{max_sectors}=="240"

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7/7-4/7-4:1.0/host3/target3:0:0':
ID=="target3:0:0"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7/7-4/7-4:1.0/host3':
ID=="host3"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7/7-4/7-4:1.0':
ID=="7-4:1.0"
BUS=="usb"
DRIVER=="usb-storage"
SYSFS{modalias}=="usb:v07ABpFCFEd0001dc00dsc00dp00ic08isc06ip50"
SYSFS{bInterfaceProtocol}=="50"
SYSFS{bInterfaceSubClass}=="06"
SYSFS{bInterfaceClass}=="08"
SYSFS{bNumEndpoints}=="02"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceNumber}=="00"

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7/7-4':
ID=="7-4"
BUS=="usb"
DRIVER=="usb"
SYSFS{serial}=="01B70D2D01E9"
SYSFS{product}=="Freecom Hard Drive"
SYSFS{manufacturer}=="Freecom"
SYSFS{maxchild}=="0"
SYSFS{version}==" 2.00"
SYSFS{devnum}=="2"
SYSFS{speed}=="480"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="00"
SYSFS{bcdDevice}=="0001"
SYSFS{idProduct}=="fcfe"
SYSFS{idVendor}=="07ab"
SYSFS{bMaxPower}=="500mA"
SYSFS{bmAttributes}=="c0"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{configuration}==""

looking at device '/devices/pci0000:00/0000:00:1d.7/usb7':
ID=="usb7"
BUS=="usb"
DRIVER=="usb"
SYSFS{serial}=="0000:00:1d.7"
SYSFS{product}=="EHCI Host Controller"
SYSFS{manufacturer}=="Linux 2.6.20-1.2320.fc5 ehci_hcd"
SYSFS{maxchild}=="8"
SYSFS{version}==" 2.00"
SYSFS{devnum}=="1"
SYSFS{speed}=="480"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="01"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="09"
SYSFS{bcdDevice}=="0206"
SYSFS{idProduct}=="0000"
SYSFS{idVendor}=="0000"
SYSFS{bMaxPower}==" 0mA"
SYSFS{bmAttributes}=="e0"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"
SYSFS{configuration}==""

looking at device '/devices/pci0000:00/0000:00:1d.7':
ID=="0000:00:1d.7"
BUS=="pci"
DRIVER=="ehci_hcd"
SYSFS{msi_bus}==""
SYSFS{broken_parity_status}=="0"
SYSFS{enable}=="1"
SYSFS{modalias}=="pci:v00008086d0000265Csv00001458sd00005006bc0Csc03i20"
SYSFS{local_cpus}=="1"
SYSFS{irq}=="17"
SYSFS{class}=="0x0c0320"
SYSFS{subsystem_device}=="0x5006"
SYSFS{subsystem_vendor}=="0x1458"
SYSFS{device}=="0x265c"
SYSFS{vendor}=="0x8086"

looking at device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""

[root@mediaserver136 rules.d]#
[root@mediaserver136 rules.d]# clear
[root@mediaserver136 rules.d]# vi /fisrtport.out
SYSFS{configuration}==""

looking at device '/devices/pci0000:00/0000:00:1d.7':
ID=="0000:00:1d.7"
BUS=="pci"
DRIVER=="ehci_hcd"
SYSFS{msi_bus}==""
SYSFS{broken_parity_status}=="0"
SYSFS{enable}=="1"
SYSFS{modalias}=="pci:v00008086d0000265Csv00001458sd00005006bc0Csc03i20"
SYSFS{local_cpus}=="1"
SYSFS{irq}=="17"
SYSFS{class}=="0x0c0320"
SYSFS{subsystem_device}=="0x5006"
SYSFS{subsystem_vendor}=="0x1458"
SYSFS{device}=="0x265c"
SYSFS{vendor}=="0x8086"

looking at device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""


***************************************************************************

Thanks
 
Old 08-06-2007, 06:35 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,353

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Why do you care ???.
The idea is to present a name to the user (via your rule(s) ) that is consistent.

Chasing device ids is "old hat" - and counter-productive to the way development is proceeding.
 
Old 08-06-2007, 07:14 AM   #3
jjamesis
LQ Newbie
 
Registered: Nov 2006
Posts: 12

Original Poster
Rep: Reputation: 0
udevinfo - how do I uniquely identify the port a usb is on Reply to Thread

I don't think you understand what I'm getting at.

Say USB A is plugged into slot A, it is given the address /dev/sdb.

USB B is plugged into slot B it is given the address /dev/sdc.

Once I reboot the machine (I've tried this about a 100 times) the addresses swap e.g. USB A becomes /dev/sdc and USB B becomes /dev/sdb.

I want to use udev to try and give persistent names. I was able to get it working by writing a rule using the serial id attribute. This will work only for the specific usb. I need it to work for any usb, that why I though about using the port as this should never change.

If this is "old hat" please recommend any better ideas.
 
Old 08-06-2007, 07:43 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,353

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
You're right - I probably don't understand.
Whenever you plug in your USB, you get a device named /dev/usb_1 Why don't you use that ???.

If you insist on particular ports being particular names, try setting up rules based on ID I guess.
 
Old 08-07-2007, 08:31 AM   #5
jjamesis
LQ Newbie
 
Registered: Nov 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00
Whenever you plug in your USB, you get a device named /dev/usb_1 Why don't you use that ???.
Thats not the case. I used SYSFS(serial} which would mean (unless I'm mistaken) only that particular USB, with that exact serial number will be named /dev/usb_1. Any other usb will result in a different device name.

Quote:
Originally Posted by syg00
If you insist on particular ports being particular names, try setting up rules based on ID I guess.
I tried using the ID=="7-4:1.0" but even this changes after a couple of reboots. Does anyone know what other ID I can use which won't change.
 
  


Reply


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
udevinfo is maxing out the CPU rsmccain Suse/Novell 3 06-04-2007 11:40 AM
Understanding dmesg output, and udevinfo... nutnut Linux - Hardware 7 05-14-2007 12:08 AM
need help using udevinfo dr_zayus69 Linux - Hardware 1 08-20-2005 05:03 AM
QUIZ!-indentifying packets uniquely... alaios Linux - Networking 4 03-29-2005 09:47 PM
suse wont identify my ethernet port rbk25 Linux - Networking 5 06-20-2004 01:40 PM


All times are GMT -5. The time now is 01:48 PM.

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