You are not logged in.
Pages: 1
Hi, i'm using udev to automount my usb storage drives, which actually works great. Additionally i want to exclude some of my drives from automounting.
My rules to symlink the drives i want to mount manually.
ATTRS{serial}=="2HA178SL ", KERNEL=="sd?1", NAME="%k", SYMLINK+="onetouch1", GROUP="storage"
ATTRS{serial}=="2HA178SL ", KERNEL=="sd?2", NAME="%k", SYMLINK+="onetouch2", GROUP="storage"
ATTRS{serial}=="6f53aa34749675", KERNEL=="sd?1", NAME="%k", SYMLINK+="myflash1", GROUP="storage"
ATTRS{product}=="GX10", KERNEL=="sd?1", NAME="%k", SYMLINK+="gx10", GROUP="storage"
My rules for automounting usb storage (sda & sdb are my harddrives):
KERNEL=="sd[c-z]", NAME="%k", SYMLINK+="usb%m", GROUP="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", SYMLINK+="usb%n", GROUP="users", NAME="%k"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mkdir -p /mnt/storage/usb%n"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/ln -s /mnt/storage/usb%n /home/machete/Desktop"
ACTION=="add", KERNEL=="sd[c-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=0022,fmask=0133,uid=1002,gid=100 /dev/%k /mnt/storage/usb%n", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="ntfs", RUN+="/bin/mount -t ntfs-3g -o rw,noauto,users,nodev,nosuid,noexec,noatime,dmask=0022,fmask=0133,uid=1002,gid=100 /dev/%k /mnt/storage/usb%n", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /mnt/storage/usb%n", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/umount -l /mnt/storage/usb%n"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/rm /home/machete/Desktop/usb%n"
ACTION=="remove", KERNEL=="sd[c-z][0-9]", RUN+="/bin/rmdir /mnt/storage/usb%n", OPTIONS="last_rule"
I tried to exclude the certain drives by negotiating ATTRS values in my rules so it looked like this:
KERNEL=="sd[c-z]", ATTRS{serial}!="2HA178SL ", NAME="%k", SYMLINK+="usb%m", GROUP="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[c-z][0-9]", ATTRS{serial}!="2HA178SL ", SYMLINK+="usb%n", GROUP="users", NAME="%k"
...
But this doesn't seem to work. Is there any way to get it to work using udev ?
Thanks in advance.
Last edited by machete (2008-06-02 13:47:36)
Offline
Assuming that all rules are in the same file and the rules for the drives that you want to mount only manually are first and before the automount rules section, you could do it with the following structure:
...
rules for the devices that are to be mounted only manually. for each rule add at the end of the line: , GOTO="skip_the_automounting_rules"
...
ordinary automounting rules (no modifications required)
...
LABEL="skip_the_automounting_rules"
This should be much easier. Also you should know that this only skips automounting rules and if there are some other rules that work with these devices they will also be executed. For this reason it's better to use ":=" than just "=" in GROUP filed at least. This ensures that it won't be changed later by some other rule.
I'm also assuming that your symlinking rules work fine and produce the desired symlinks.
Offline
thanks for your help. i got the idea and it's working great.
Offline
Pages: 1