LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 10-11-2006, 10:08 AM   #1
Steve50
Member
 
Registered: Nov 2004
Location: Coventry, UK
Distribution: Debian Lenny, Ubuntu Feisty
Posts: 121

Rep: Reputation: 15
udev rule for usbstick


I've been trying to create a udev rule for my usbstick so that I can add an entry to fstab. I can mount it manually without any problems once I've found out what device node it's mapped to - but this often changes because I have sata drives, card readers, and other usb devices. So I created /etc/udev/rules.d/local.rules and added this entry:

BUS="usb", SYSFS{serial}="0A315B503230C892", SYSFS{product}="disgo", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick"

I wanted to create a persistent symlink to /dev/usbstick, but it doesn't work. Any ideas anyone?
 
Old 10-11-2006, 10:13 AM   #2
marnold
Member
 
Registered: Dec 2005
Distribution: Slackware64 14.1
Posts: 258

Rep: Reputation: 32
Here's the rule I used:

BUS=="scsi", KERNEL=="sd*", SYSFS{vendor}=="OTi", SYSFS{model}=="Flash Disk", NAME="%k", SYMLINK+="usbdrive"

Note: this is with Slackware 11.0. The rule format changed quite a bit between the versions of udev that came with 10.2 and 11.0.
 
Old 10-11-2006, 10:24 AM   #3
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,379

Rep: Reputation: Disabled
Maybe (if you're running Slackware 11.0) you should look in /dev/disk where symlinks for every disk device are created by id, label, uuid and path.

My USB stick (/dev/sda) is there as follows:

Code:
$ ls -la /dev/disk/by-label/ | grep sda
lrwxrwxrwx 1 root root 10 2006-10-11 16:21 /dev/disk/by-label/ZIPSLACK -> ../../sda1

$ ls -la /dev/disk/by-id/ | grep sda
lrwxrwxrwx 1 root root   9 2006-10-11 16:21 usb-JetFlash_TS256MJF2B.2L_61103E90297C0009 -> ../../sda
lrwxrwxrwx 1 root root  10 2006-10-11 16:21 usb-JetFlash_TS256MJF2B.2L_61103E90297C0009-part1 -> ../../sda1

$ ls -la /dev/disk/by-uuid/ | grep sda
lrwxrwxrwx 1 root root  10 2006-10-11 16:21 4522-B5D2 -> ../../sda1

ll /dev/disk/by-path/ | grep sda
lrwxrwxrwx 1 root root   9 2006-10-11 16:21 pci-0000:00:02.2-usb-0:4:1.0-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root  10 2006-10-11 16:21 pci-0000:00:02.2-usb-0:4:1.0-scsi-0:0:0:0-part1 -> ../../sda1
One of these will allow you to create a fixed /etc/fstab entry at least.

Eric
 
Old 10-11-2006, 10:50 AM   #4
Steve50
Member
 
Registered: Nov 2004
Location: Coventry, UK
Distribution: Debian Lenny, Ubuntu Feisty
Posts: 121

Original Poster
Rep: Reputation: 15
Many thanks to both of you. marnoid, I tried rewriting the udev rule but unfortunately it still didn't work, so I looked at Bob's suggestion and added this entry to fstab:

/dev/disk/by-label/disgo /mnt/usbstick vfat rw,user,noauto,umask=000 0 0

It seems to work fine, and I didn't realise you could do this. Many thanks again to both of you.
 
Old 10-13-2006, 06:34 AM   #5
BeerIsGood
LQ Newbie
 
Registered: Aug 2005
Location: Emerald, Queensland, Australia
Distribution: Kubuntu => moving => Debian 6
Posts: 27
Blog Entries: 1

Rep: Reputation: 0
Steve50, I realise that you have worked around your initial problem, however if you're still interested, I think the cause of your rule falling over is syntax. Your rule:
Code:
BUS="usb", SYSFS{serial}="0A315B503230C892", SYSFS{product}="disgo", KERNEL="sd?1", NAME="%k", SYMLINK="usbstick"
The matchkey must use the equality operator (==). A single (=) is the assignment operator, except for when you assign a SYMLINK, which uses "+=".

Also, I think that the serial and product SYSFS keys (and possibly kernel key) are enough to identify your deivce. I can't see the name key doing anything, since it says, "match a device that was named by the kernel with the name that the kernel gave it".

Therefore, the rule should probably look more like:
Code:
BUS = "usb", SYSFS{serial}=="0A315B503230C892", SYSFS{product}=="disgo", KERNEL=="sd?1", SYMLINK+="usbstick"
As well as the /dev/sd?1 node, you would get /dev/usbstick, which is a consistently named symlink to your usb stick, whether it be /dev/sda1, /dev/sdb1, etc.

I've been doing a lot of reading on udev to fix a few problems lately, but am no expert, I assure you. My apologies if I lead you up the garden path, but I find it's a nice garden anyhow, if you have the time. I highly recommend Writing udev rules by Daniel Drake.
[edit: changed my mind about needing BUS = "usb"]

Last edited by BeerIsGood; 10-13-2006 at 06:45 AM.
 
Old 10-13-2006, 06:53 AM   #6
Steve50
Member
 
Registered: Nov 2004
Location: Coventry, UK
Distribution: Debian Lenny, Ubuntu Feisty
Posts: 121

Original Poster
Rep: Reputation: 15
Hi BeerIsGood. Thanks for this follow up. After creating the working fstab entry I also needed to create a udev rule for my wacom tablet, and I ended up doing a fair bit of research, including reading the reference in your post. And you're right, the syntax in my first rule was completely wrong (I believe it changed relatively recently)and after playing around with it I ended up with a working rule that looked very similar to yours. I was also able to create a symlink for my wacom that made configuring xorg.conf entries much easier. The key seems to be the use of the "==" for SYSFS and KERNEL entries and "+=" for the SYMLINK, although I'm sure there's a lot more to it. I'll keep reading.

Cheers

Steve

Last edited by Steve50; 10-13-2006 at 06:54 AM.
 
  


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
Udev rule required for scsi scanner samac Slackware 2 10-07-2006 11:32 AM
udev-Rule for Mobile tuxangler Linux - Hardware 1 03-28-2006 06:41 AM
Making a udev rule for sonypi blimbo Linux - Software 4 03-01-2006 08:48 PM
Wrong group with custom udev rule enragedchip Linux - Hardware 1 12-11-2005 03:46 PM
Issues with adding a udev rule... Ateo Linux - General 1 03-04-2005 09:02 PM


All times are GMT -5. The time now is 10:04 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration