On Wed, Jan 14, 2009 at 10:45:16PM +0100, Josef Wolf wrote:
Finally, I've (almost) figured out how to do what Randall and myself want, and it turns out that all this can be done by udev directly. No ivman needed.
I've put into /etc/udev/rules.d/80-my-backup-mounts.rules the following:
ACTION=="add", # when device is attached KERNEL=="sd[a-z][0-9]*", # and matches this pattern PROGRAM="/lib/udev/vol_id -l %N", # retrieve filesystem label RESULT=="na-ppc-[0-9]*", # label has to match this pattern RUN+="/bin/mkdir -p /media/$result", # create mountpoint and mount RUN+="/bin/mount -orw,nodev,nosuid,noexec,noatime /dev/%k /media/$result", OPTIONS="last_rule" # abort processing
All this must be a single line and comments are to be removed.
All the labels of my backup drives match the regex /^na-ppc-\d+$/ and the RESULT rule makes sure that everything else is ignored by this rule. Unfortunately, udevd understands only simple shell-style globbing.
Then I run "udevadm control --reload-rules"
This (almost) does what we both (and maybe others?) want. The OPTIONS="last_rule" stops further processing and therefore prevents the event to be forwarded to HAL and the desktop (that is the "manually" part of Randall's question)
The only problem that I could not figure out (yet) is that of the RUN array: only the last command (the mount in this case) is run.
I've got it now: simply duplicate the rule. The first one should contain the RUN+="mount ..." and the second should contain the run+="mount ..." But there are two more points on my wishlist: - how do I rmdir the mount point when the device is removed? This turns out to be somewhat tricky, since the device node will already be gone and vol_id won't work anymore. - Is there any possibility to automatically umount when the device is removed? Guess this would require to activate the sync mount option? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org