Results 1 to 1 of 1
Hello... I'm using udev rules to automount USB drives to their own directories in /media. Currently I have a file /etc/udev/rules.d/usb.rules which looks like this:
Code:
KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", ...
- 04-13-2009 #1Just Joined!
- Join Date
- Jul 2005
- Posts
- 72
udev rules for automounting USB sticks, and behavior with ROX
Hello... I'm using udev rules to automount USB drives to their own directories in /media. Currently I have a file /etc/udev/rules.d/usb.rules which looks like this:
(I got this from the Arch Linux wiki...)Code:KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", OPTIONS="last_rule" ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k" ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k" ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k" ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%k", OPTIONS="last_rule" ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule" ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k" ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k" ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"
This works for USB devices labeled /dev/sdXY. However, I've got some problems with it...
1. When I try to unmount said USB device from within ROX (the file manager I'm using), I get an error - "/dev/sdXY is not in fstab (and you are not root)". How can I modify the rules so that ROX can unmount the drives?
2. These rules don't handle USB sticks that are completely formatted (e.g. labeled /dev/sdX as opposed to /dev/sdXY).
3. It looks like it wouldn't handle USB CD drives or floppy drives properly.
Actually, what would be nice is a complete set of udev rules for dealing with USB and PCMCIA devices, something along the lines of Vector Linux's vl-hot. Are there any other things like that?


Reply With Quote
