You are not logged in.

#1 2010-01-07 20:51:18

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Problem with custom udev rules

I created the following udev rules to mount devices with labels:

KERNEL!="sd[b-z][0-9]", GOTO="end_automount"
PROGRAM!="/lib/initcpio/udev/vol_id --label %N", GOTO="end_automount"

ACTION=="add", ENV{mount_options}="auto,users,rw,uid=000,gid=000"

ACTION=="add", ENV{ID_FS_LABEL}=="M2HDb", RUN+="/bin/mount /media/M2HDb"
ACTION=="add", ENV{ID_FS_LABEL}!="M2HDb", RUN+="/bin/su -c '/bin/mount /media/$env{ID_FS_LABEL} -o $env{mount_options}' barrucadu"

LABEL="end_automount"

But… nothing is getting mounted. sad

The devices are all in /etc/fstab, so the mount commands seem fine.

Last edited by Barrucadu (2010-01-07 20:54:13)

Offline

#2 2010-01-07 21:04:18

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: Problem with custom udev rules

Have you tried the rule listed in the wiki?

KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime,users"
# Filesystem specific options
ACTION=="add", PROGRAM=="/lib/initcpio/udev/vol_id -t %N", RESULT=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

ACTION=="add", PROGRAM=="/lib/initcpio/udev/vol_id --label %N", ENV{dir_name}="%c"
ACTION=="add", PROGRAM!="/lib/initcpio/udev/vol_id --label %N", ENV{dir_name}="usbhd-%k"
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
ACTION=="remove", ENV{dir_name}=="?*", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
LABEL="media_by_label_auto_mount_end"

Offline

#3 2010-01-07 21:30:21

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Problem with custom udev rules

I derived my rule from the wiki article; I've just noticed it works if I replace my two mounting rules with this one rule:

ACTION=="add", RUN+="/bin/mount /media/$env{ID_FS_LABEL} -o $env{mount_options}"

But then I have to unmount everything with sudo, which isn't ideal.

Offline

Board footer

Powered by FluxBB