Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USB automount with udev: out of ideas
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
k_klunz
n00b
n00b


Joined: 03 Dec 2004
Posts: 36
Location: Kaiserslautern, Rheinland-Pfalz, Germany, Europe

PostPosted: Sun Jan 31, 2016 2:13 pm    Post subject: USB automount with udev: out of ideas Reply with quote

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
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1555
Location: Montréal

PostPosted: Sun Jan 31, 2016 3:35 pm    Post subject: Reply with quote

Autofs is a good tool to automount mass medias and network shares. Of course, I must already know which partition and filesystem I want it to automount when I configure it. I have never try to make it work when the partitions table and the filesystems change 'dynamically' on a media. I don't know yet if it is possible.
_________________
Paul
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum