You are not logged in.

#1 2008-06-07 22:04:42

dante4d
Member
From: Czech Republic
Registered: 2007-04-14
Posts: 176

Howto: usb drive & flash pen automount

I'd like to share my udev rules for usb drive & flash pen automount:

KERNEL=="sd?1", ATTRS{vendor}=="Corsair", ATTRS{model}=="Flash Voyager", NAME="%k", SYMLINK+="voyager"
ACTION=="add", KERNEL=="sd?1", ATTRS{vendor}=="Corsair", ATTRS{model}=="Flash Voyager", RUN+="/bin/mkdir /mnt/voyager"
ACTION=="add", KERNEL=="sd?1", ATTRS{vendor}=="Corsair", ATTRS{model}=="Flash Voyager", RUN+="/bin/mount -t vfat -o sync,flush,uid=1000,gid=100 /dev/voyager /mnt/voyager"
ACTION=="remove", KERNEL=="sd?1", ENV{ID_VENDOR}=="Corsair", ENV{ID_MODEL}="Flash_Voyager", RUN+="/bin/umount /mnt/voyager"
ACTION=="remove", KERNEL=="sd?1", ENV{ID_VENDOR}=="Corsair", ENV{ID_MODEL}="Flash_Voyager", RUN+="/bin/rmdir /mnt/voyager"

KERNEL=="sd?1", ATTRS{vendor}=="WD", ATTRS{model}=="1600BEV External", NAME="%k", SYMLINK+="passport"
ACTION=="add", KERNEL=="sd?1", ATTRS{vendor}=="WD", ATTRS{model}=="1600BEV External", RUN+="/bin/mkdir /mnt/passport"
ACTION=="add", KERNEL=="sd?1", ATTRS{vendor}=="WD", ATTRS{model}=="1600BEV External", RUN+="/bin/mount -t vfat -o sync,flush,uid=1000,gid=100 /dev/passport /mnt/passport"
ACTION=="remove", KERNEL=="sd?1", ENV{ID_VENDOR}=="WD", ENV{ID_MODEL}="1600BEV_External", RUN+="/bin/umount /mnt/passport"
ACTION=="remove", KERNEL=="sd?1", ENV{ID_VENDOR}=="WD", ENV{ID_MODEL}="1600BEV_External", RUN+="/bin/rmdir /mnt/passport"

That's what I came up with consulting guide Writing udev rules guide.
I've run into problem that was not immediately obvious to me. Udev won't recognize devices by ATTRS match-keys on remove. I had to use ENV keys, like guy in this thread.
Everything seems to work fine cool. I'll see if my files start disappearing from my external drive tongue.

Any suggestions for improvement (like better mount options)?
Thanks

Offline

Board footer

Powered by FluxBB