k_klunz n00b
Joined: 03 Dec 2004 Posts: 36 Location: Kaiserslautern, Rheinland-Pfalz, Germany, Europe
|
Posted: Sun Jan 31, 2016 2:13 pm Post subject: USB automount with udev: out of ideas |
|
|
Hello everyone,
I've been trying since yesterday to get automount for my external USB-drives working with udev.
I know about alternatives like uam, but I would just like to be able to control the behaviour, therefore I would like tu use a udev rule.
At the moment the rule looks like this:
Code: | KERNEL!="sd[b-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
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"
# Global mount options
ACTION=="add", ENV{mount_options}="users"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{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 rule is basically taken from https://wiki.archlinux.org/index.php/Udev, when it did not work out of the box I tried to minimize it to the necessary parts, so that I understand whats happening.
My login user is in the users und plugdev groups.
When I enable udev-loging, I get the following in my systemlog when plugging in an usb-stick:
Code: | Jan 31 15:04:07 localhost kernel: usb 2-2: new SuperSpeed USB device number 3 using xhci_hcd
Jan 31 15:04:07 localhost kernel: usb 2-2: New USB device found, idVendor=1b1c, idProduct=1a0a
Jan 31 15:04:07 localhost kernel: usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 31 15:04:07 localhost kernel: usb 2-2: Product: Survivor 3.0
Jan 31 15:04:07 localhost kernel: usb 2-2: Manufacturer: Corsair
Jan 31 15:04:07 localhost kernel: usb 2-2: SerialNumber: 07084671F3943F76
Jan 31 15:04:07 localhost kernel: usb-storage 2-2:1.0: USB Mass Storage device detected
Jan 31 15:04:07 localhost kernel: scsi host8: usb-storage 2-2:1.0
Jan 31 15:04:07 localhost mtp-probe[9606]: checking bus 2, device 3: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2"
Jan 31 15:04:07 localhost mtp-probe[9606]: bus: 2, device: 3 was not an MTP device
Jan 31 15:04:08 localhost kernel: scsi 8:0:0:0: Direct-Access Corsair Survivor 3.0 000A PQ: 0 ANSI: 6
Jan 31 15:04:08 localhost kernel: sd 8:0:0:0: Attached scsi generic sg2 type 0
Jan 31 15:04:08 localhost kernel: sd 8:0:0:0: [sdc] 31326208 512-byte logical blocks: (16.0 GB/14.9 GiB)
Jan 31 15:04:08 localhost kernel: sd 8:0:0:0: [sdc] Write Protect is off
Jan 31 15:04:08 localhost kernel: sd 8:0:0:0: [sdc] Mode Sense: 2b 00 00 08
Jan 31 15:04:08 localhost kernel: sd 8:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jan 31 15:04:09 localhost kernel: sdc: sdc1 sdc2
Jan 31 15:04:09 localhost kernel: sd 8:0:0:0: [sdc] Attached SCSI removable disk
Jan 31 15:04:09 localhost kernel: kjournald starting. Commit interval 5 seconds
Jan 31 15:04:09 localhost kernel: EXT3-fs (sdc2): using internal journal
Jan 31 15:04:09 localhost kernel: EXT3-fs (sdc2): recovery complete
Jan 31 15:04:09 localhost kernel: EXT3-fs (sdc2): mounted filesystem with writeback data mode
Jan 31 15:04:09 localhost kernel: FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
|
I dont see a mount error here (I already saw mount-errors in the log before, when I had an error in my rule), it even says that sdc2 was mounted. Furthermore, I see that the directories that correspond to the ID_FS_LABEL are created in the correct place.
However, the directories are empty, and dont show up when I umount <TAB>.
I have a feeling that there is something amiss somewhere else, that I just dont see right now.
Any help would be greatly appreciated, thanks in advance.
Many greeting and have a nice sunday
Tobe |
|