udev rule to enable automounting with acl support

Asked by nokangaroo

I am trying to create a udev rule that will allow me to mount an ext4 disk with acl option while preserving user unmountability. The following rule (adapted from https://wiki.archlinux.org/index.php/Udev#About_udev_rules) will work, but I have to unmount the volume partition by partition; there is no "Safely remove drive". Adding myself to the "disk" group won't work either, or changing device node permissions. I also tried using pmount, but that has no acl option and is therefore useless.

# Leave sda to fstab
KERNEL!="sd[b-z]*", GOTO="media_by_label_auto_mount_end"

# We are handling only ext4 partitions
ENV{ID_FS_TYPE}!="ext4", GOTO="media_by_label_auto_mount_end"

# Import FS info
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Mount options
ACTION=="add", ENV{mount_options}="nodev,nosuid,relatime,acl,uhelper=udisks"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -t %E{ID_FS_TYPE} -o %E{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

This works when copied to /etc/udev/rules.d/11-some-name.rules or /etc/udev/user.rules (the exact number does not seem to matter much; at present the filename is 69-local.rules), but unmounting as user does not work properly, also the devices appear twice in the nautilus side pane (a sure sign that something is fishy). Does udev use mount at all by default? And what else is there?

The file /lib/udev/rules.d/50-udev-default.rules does not seem to have a KERNEL=="sd*" entry at all, so maybe that's the problem. A half-solution is to add a mount -o remount,acl line to my backup scripts, but mount will hang when another program is accessing the disk.

Another problem is that the entries in /media will remain if the disk is unmounted but not actually unplugged, which will cause my backup scripts to fill up the root partition (this never happens with the default udev setup. Of course I could rewrite the scripts if necessary, but I'd rather fix this behaviour).

I am using ubuntu maverick with kernel 2.6.35-29-generic.

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu udev Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
nokangaroo (nokangaroo-deactivatedaccount-deactivatedaccount) said :
#1

Update: I find that if the disk is plugged in at boottime, I get "Safely remove Drive" AND acl support, and the boot log (with setting "debug" in /etc/udev/udev.conf) contains lots of entries "udevd-work [xxx]" where xxx is a 3-digit number, but it does not contain the words "ext4","sdb"(except for devices not handled by the rule), or the UUID of the disk, and it is encyclopaedic, so I guess it makes no sense printing it here (I will do so on request).

I suspect that the udev rule is okay; the problem lies somewhere else.

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.