LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-27-2006, 07:23 PM   #1
doralsoral
Member
 
Registered: Aug 2003
Location: raleigh
Distribution: Gentoo 2005.1 x86_64
Posts: 931

Rep: Reputation: 31
writing udev rules


I want to set my system up so when i plug it my usb hard disk, my camera, and my ipod they are always the same dev name so i can have them automounted. right now when i plug them in they always end up changing to something different than the last time i plugged them in so the fstab entry is useless. I've read some howtos on writing udev rules but i can't seem to get it going. can someone give me a hand?
 
Old 10-27-2006, 08:06 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Here's my /etc/udev/rules.d/10-cronus.rules to start with:
Code:
KERNEL=="sd?1", SYSFS{manufacturer}=="Sony", SYMLINK+="sony"
KERNEL=="sd?1", SYSFS{product}=="Cruzer Mini", SYMLINK+="cruzer"
KERNEL=="sd?1", SYSFS{product}=="LaCie Hard Drive USB", SYMLINK+="backup"
KERNEL=="sd?2", SYSFS{product}=="LaCie Hard Drive USB", SYMLINK+="transport"
KERNEL=="sd?2", SYSFS{product}=="iPod mini", SYMLINK+="ipod"
So when I plug in my iPod, I get a '/dev/ipod' device, linked to the data-holding /dev/sdX2 partition.
The LaCie drive has two partitions (differentiated by sd?1 and sd?2).

To get all the udev info for a device, run the following:
Code:
udevinfo -a -p `udevinfo -q path -n /dev/DEVICE`
and pick something unique to differentiate the device/partition.

This is the output when the LaCie drive is plugged in and is at /dev/sda, as an example:
Code:
[root@cronus ~]# udevinfo -a -p `udevinfo -q path -n /dev/sda`

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/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    SYSFS{stat}=="     107      824     1260      390        0        0        0        0        0      227      390"
    SYSFS{size}=="488397168"
    SYSFS{removable}=="0"
    SYSFS{range}=="16"
    SYSFS{dev}=="8:0"

  looking at device '/devices/pci0000:00/0000:00:10.3/usb1/1-3/1-3:1.0/host0/target0:0:0/0:0:0:0':
    ID=="0:0:0:0"
    BUS=="scsi"
    DRIVER=="sd"
    SYSFS{ioerr_cnt}=="0x0"
    SYSFS{iodone_cnt}=="0x72"
    SYSFS{iorequest_cnt}=="0x72"
    SYSFS{iocounterbits}=="32"
    SYSFS{timeout}=="60"
    SYSFS{state}=="running"
    SYSFS{rev}=="15.0"
    SYSFS{model}=="WD2500JB-00FUA0 "
    SYSFS{vendor}=="WDC     "
    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:10.3/usb1/1-3/1-3:1.0/host0/target0:0:0':
    ID=="target0:0:0"
    BUS==""
    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:10.3/usb1/1-3/1-3:1.0/host0':
    ID=="host0"
    BUS==""
    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:10.3/usb1/1-3/1-3:1.0':
    ID=="1-3:1.0"
    BUS=="usb"
    DRIVER=="usb-storage"
    SYSFS{modalias}=="usb:v059Fp0351d0000dc00dsc00dp00ic08isc06ip50"
    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:10.3/usb1/1-3':
    ID=="1-3"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{serial}=="10000E0008529A96"
    SYSFS{product}=="LaCie Hard Drive USB"
    SYSFS{manufacturer}=="LaCie"
    SYSFS{maxchild}=="0"
    SYSFS{version}==" 2.00"
    SYSFS{devnum}=="4"
    SYSFS{speed}=="480"
    SYSFS{bMaxPacketSize0}=="64"
    SYSFS{bNumConfigurations}=="1"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="00"
    SYSFS{bcdDevice}=="0000"
    SYSFS{idProduct}=="0351"
    SYSFS{idVendor}=="059f"
    SYSFS{bMaxPower}=="  2mA"
    SYSFS{bmAttributes}=="c0"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:10.3/usb1':
    ID=="usb1"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{serial}=="0000:00:10.3"
    SYSFS{product}=="EHCI Host Controller"
    SYSFS{manufacturer}=="Linux 2.6.18.1cronus ehci_hcd"
    SYSFS{maxchild}=="6"
    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"

  looking at device '/devices/pci0000:00/0000:00:10.3':
    ID=="0000:00:10.3"
    BUS=="pci"
    DRIVER=="ehci_hcd"
    SYSFS{broken_parity_status}=="0"
    SYSFS{enable}=="1"
    SYSFS{modalias}=="pci:v00001106d00003104sv00001458sd00005004bc0Csc03i20"
    SYSFS{local_cpus}=="1"
    SYSFS{irq}=="19"
    SYSFS{class}=="0x0c0320"
    SYSFS{subsystem_device}=="0x5004"
    SYSFS{subsystem_vendor}=="0x1458"
    SYSFS{device}=="0x3104"
    SYSFS{vendor}=="0x1106"

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

Last edited by ilikejam; 10-27-2006 at 08:10 PM.
 
Old 10-28-2006, 10:12 AM   #3
doralsoral
Member
 
Registered: Aug 2003
Location: raleigh
Distribution: Gentoo 2005.1 x86_64
Posts: 931

Original Poster
Rep: Reputation: 31
Hey that helped me a lot, the only thing i can't get working is my usb card reader. Do you know how to set one of these up, if it makes it easier i only have one kind of card i need read.
 
Old 10-28-2006, 11:21 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Plug in the card reader (and card), and post the output from:

udevinfo -a -p `udevinfo -q path -n /dev/DEVICE`

where DEVICE is the sdX device which appears when you plug it in.

Dave
 
Old 10-28-2006, 12:52 PM   #5
doralsoral
Member
 
Registered: Aug 2003
Location: raleigh
Distribution: Gentoo 2005.1 x86_64
Posts: 931

Original Poster
Rep: Reputation: 31
looking at device '/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
SYSFS{stat}==" 0 0 0 0 0 0 0 0 0 0 0"
SYSFS{size}=="0"
SYSFS{removable}=="1"
SYSFS{range}=="16"
SYSFS{dev}=="8:16"

looking at device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host9/target9:0:0/9:0:0:0':
ID=="9:0:0:0"
BUS=="scsi"
DRIVER=="sd"
SYSFS{ioerr_cnt}=="0x43b3"
SYSFS{iodone_cnt}=="0x43b4"
SYSFS{iorequest_cnt}=="0x43b4"
SYSFS{iocounterbits}=="32"
SYSFS{timeout}=="30"
SYSFS{state}=="running"
SYSFS{rev}=="3.95"
SYSFS{model}=="Flash HS-CF"
SYSFS{vendor}=="Generic "
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:02.2/usb1/1-5/1-5:1.0/host9/target9:0:0':
ID=="target9:0:0"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host9':
ID=="host9"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0':
ID=="1-5:1.0"
BUS=="usb"
DRIVER=="usb-storage"
SYSFS{modalias}=="usb:v050Dp0211d0395dc00dsc00dp00ic08isc06ip50"
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:02.2/usb1/1-5':
ID=="1-5"
BUS=="usb"
DRIVER=="usb"
SYSFS{configuration}==""
SYSFS{serial}=="0504062049D6"
SYSFS{product}=="15 in 1 MEDIA READER USB 2.0"
SYSFS{manufacturer}=="BELKIN"
SYSFS{maxchild}=="0"
SYSFS{version}==" 2.00"
SYSFS{devnum}=="8"
SYSFS{speed}=="480"
SYSFS{bMaxPacketSize0}=="64"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="00"
SYSFS{bcdDevice}=="0395"
SYSFS{idProduct}=="0211"
SYSFS{idVendor}=="050d"
SYSFS{bMaxPower}==" 96mA"
SYSFS{bmAttributes}=="80"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"

looking at device '/devices/pci0000:00/0000:00:02.2/usb1':
ID=="usb1"
BUS=="usb"
DRIVER=="usb"
SYSFS{configuration}==""
SYSFS{serial}=="0000:00:02.2"
SYSFS{product}=="EHCI Host Controller"
SYSFS{manufacturer}=="Linux 2.6.17-gentoo-r8 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"

looking at device '/devices/pci0000:00/0000:00:02.2':
ID=="0000:00:02.2"
BUS=="pci"
DRIVER=="ehci_hcd"
SYSFS{modalias}=="pci:v000010DEd000000E8sv00001043sd0000813Fbc0Csc03i20"
SYSFS{local_cpus}=="1"
SYSFS{irq}=="193"
SYSFS{class}=="0x0c0320"
SYSFS{subsystem_device}=="0x813f"
SYSFS{subsystem_vendor}=="0x1043"
SYSFS{device}=="0x00e8"
SYSFS{vendor}=="0x10de"

looking at device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""
 
Old 10-30-2006, 09:38 PM   #6
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi again.

Try the following:
Code:
KERNEL=="sd?1", SYSFS{product}=="15 in 1 MEDIA READER USB 2.0", SYMLINK+="cardreader"
That should create a '/dev/cardreader' device for the first (and probably only) partition of any card you put in the card reader.

Dave
 
Old 10-31-2006, 08:10 AM   #7
doralsoral
Member
 
Registered: Aug 2003
Location: raleigh
Distribution: Gentoo 2005.1 x86_64
Posts: 931

Original Poster
Rep: Reputation: 31
That doesn't even create device nodes
 
Old 10-31-2006, 10:55 AM   #8
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
ORLY?

How about:
Code:
KERNEL=="sd?", SYSFS{product}=="15 in 1 MEDIA READER USB 2.0", SYMLINK+="cardreader"
 
Old 11-18-2006, 05:30 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
I'm also trying to install a cardreader. It's a Microtech CameraMate. My system is Debian 2.6.8. When I mount the CameraMate, the mounted filesystem gives me 4 directories (001, 002, 003, 004) as well as a file named devices. None of the directories has any actual card data in it. The devices file doesn't have anything really useful, either. IOW, I can mount the device, but I can't get at the picture my camera put on it. I checked the card again on the camera, and the picture is fine. I enabled the verbose usb debugging messages, and I get "Not Ready: Medium Not Present" on the console when I insert a card in the device.
 
Old 11-18-2006, 06:09 PM   #10
doralsoral
Member
 
Registered: Aug 2003
Location: raleigh
Distribution: Gentoo 2005.1 x86_64
Posts: 931

Original Poster
Rep: Reputation: 31
If you have a several-in-one card reader, you'll probably have to also set Device Drivers --> SCSI device support -->[*] Probe all LUNs on each SCSI device (kernel 2.6). These readers are usually set up with one slot as the primary slot, so if this option isn't set, you won't be able to see the other slots.
 
Old 11-19-2006, 02:45 AM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by Quakeboy02
I'm also trying to install a cardreader. It's a Microtech CameraMate. My system is Debian 2.6.8. When I mount the CameraMate, the mounted filesystem gives me 4 directories (001, 002, 003, 004) as well as a file named devices. None of the directories has any actual card data in it. The devices file doesn't have anything really useful, either. IOW, I can mount the device, but I can't get at the picture my camera put on it. I checked the card again on the camera, and the picture is fine. I enabled the verbose usb debugging messages, and I get "Not Ready: Medium Not Present" on the console when I insert a card in the device.
After banging on this with a largish hammer, I finally realised that my problem is not the Microtech device. The problem I have is that the camera, an old Fuji MX-1200 isn't putting data on the disk in any format that Linux can read. If I simply do mkdosfs on my cards in the CameraMate, I can use them just fine. Of course, then the Camera can't read them. The file system used by the camera seems to be almost but not quite, MSDOS. Oh well.
 
  


Reply

Tags
udev rules



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
Creating rules for udev wnaLinux Slackware 5 01-03-2008 09:21 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 03:43 AM
LXer: Writing udev rules LXer Syndicated Linux News 0 06-11-2006 11:12 PM
UDEV Rules Location Toods Slackware 1 04-28-2006 02:23 AM
need help fixing my udev rules or ivman rules hedpe Linux - Hardware 2 03-18-2006 10:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration