Mailinglist Archive: opensuse (3513 mails)

< Previous Next >
Re: [opensuse] How to mount external drives automatically?
  • From: Josef Wolf <jw@xxxxxxxxxxxxx>
  • Date: Wed, 14 Jan 2009 22:45:16 +0100
  • Message-id: <20090114214516.GC18088@xxxxxxxxxxxxxx>
On Mon, Jan 12, 2009 at 07:08:58PM -0500, Anton Aylward wrote:
Josef Wolf said the following on 01/12/2009 04:38 PM:

I am somewhat confused by this hal/udev topic. Isn't one of them
replaced/obsoleted by the other?

I was led to believe that udev had replaced all the ivman stuff.
Can anyone confirm/deny this?
Do we still need ivman to use things like USB?

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. If I use

RUN+="/bin/mkdir foo; /bin/mount bar baz"

instead, then mkdir is run with foo;, /bin/mount, bar and baz as options.

So the remaining question is: how to run multiple commands from a single
udev rule?
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups