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? |
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. |
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 Eric |
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. |
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" 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" 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"] |
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 |
All times are GMT -5. The time now is 04:01 PM. |