[solved] how to make udev automatically mount devices ?

Kernels & Hardware, configuring network, installing services

[solved] how to make udev automatically mount devices ?

Postby goulo » 2012-02-21 14:34

Hi,
I can manually mount my various external devices (CD-ROM drive, hard drive, USB memory drives) fine, but I am baffled how to get udev to automatically mount them.

E.g. plugging in the CD-ROM drive, /var/log/syslog shows:
Code: Select all
Feb 21 15:20:27 komputronik udevd[4966]: failed to execute '/lib/udev/mtp-probe' 'mtp-probe /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-3 1 5': No such file or directory
Feb 21 15:20:27 komputronik kernel: [27140.600959] usb 1-3: New USB device found, idVendor=059b, idProduct=0252
Feb 21 15:20:27 komputronik kernel: [27140.600964] usb 1-3: New USB device strings: Mfr=56, Product=63, SerialNumber=79
Feb 21 15:20:27 komputronik kernel: [27140.600968] usb 1-3: Product: Optical USB 2.0
Feb 21 15:20:27 komputronik kernel: [27140.600971] usb 1-3: Manufacturer: Iomega
Feb 21 15:20:27 komputronik kernel: [27140.600974] usb 1-3: SerialNumber: DEF109FBFA5F
Feb 21 15:20:27 komputronik kernel: [27140.601333] scsi10 : usb-storage 1-3:1.0
Feb 21 15:20:28 komputronik kernel: [27141.601133] scsi 10:0:0:0: CD-ROM            LITE-ON  DVDRW SOHW-1673S JS05 PQ: 0 ANSI: 0
Feb 21 15:20:28 komputronik kernel: [27141.604226] sr1: scsi3-mmc drive: 48x/48x writer cd/rw xa/form2 cdda tray
Feb 21 15:20:28 komputronik kernel: [27141.604491] sr 10:0:0:0: Attached scsi CD-ROM sr1

So it's being recognized and assigned to /dev/sr1, but not auto-mounted. (By the way, I assume this is unrelated to the mtp-probe message which shows up in the log as well, which has various debian bugs assigned to it https://www.google.com/search?q=udev+mtp-probe ; I have libmtp-common installed because vlc is installed, and automounting has never worked, even long before vlc was installed.)

The automounting fails on both our computers which have debian sid installed. I see via ps that udevd is running. I am new to tinkering with udev stuff; is there some simple thing I'm overlooking? As far as I can tell, udev is supposed to normally "just work", and you shouldn't normally need to explicitly create udev rules, right? (Since one of the goals is to be able to plug in arbitrary disk drives or memory sticks and have them transparently automatically mount, right?)

E.g. http://www.crazysquirrel.com/computing/debian/udev.jspx makes it sound like normally auto-mounting should "just work" and needing to write custom rules is the exception.

Verifying some obvious stuff:

/lib/udev/rules.d has plenty of rule files, including for cdrom:
Code: Select all
40-hplip.rules                    69-cd-sensors.rules
42-qemu-usb.rules                 69-libmtp.rules
50-udev-default.rules             69-xserver-xorg-input-wacom.rules
55-dm.rules                       70-udev-acl.rules
56-hpmud_support.rules            75-cd-aliases-generator.rules
60-cdrom_id.rules                 75-net-description.rules
60-fuse.rules                     75-persistent-net-generator.rules
60-gnupg.rules                    75-probe_mtd.rules
60-libgphoto2-2.rules             75-tty-description.rules
60-libsane.rules                  78-sound-card.rules
60-persistent-alsa.rules          80-drivers.rules
60-persistent-input.rules         80-networking.rules
60-persistent-serial.rules        85-hwclock.rules
60-persistent-storage-dm.rules    90-pulseaudio.rules
60-persistent-storage.rules       91-permissions.rules
60-persistent-storage-tape.rules  95-cd-devices.rules
60-persistent-v4l.rules           95-keyboard-force-release.rules
61-accelerometer.rules            95-keymap.rules
64-xorg-xkb.rules                 95-udev-late.rules

In /etc/udev/rules.d there's a file 70-persistent-cd.rules which has:
Code: Select all
# This file was automatically generated by the /lib/udev/write_cd_rules
# program, run by the cd-aliases-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and set the $GENERATED variable.

# DVD_RW_AD-7191A (pci-0000:03:00.0-scsi-0:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:03:00.0-scsi-0:0:0:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:03:00.0-scsi-0:0:0:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:03:00.0-scsi-0:0:0:0", SYMLINK+="dvd", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:03:00.0-scsi-0:0:0:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"

# DVDRW_SOHW-1673S (pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0", SYMLINK+="cdrom1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0", SYMLINK+="cdrw1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0", SYMLINK+="dvd1", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0", SYMLINK+="dvdrw1", ENV{GENERATED}="1"

# DVDRW_SOHW-1673S (pci-0000:00:1a.7-usb-0:3:1.0-scsi-0:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_SERIAL}=="LITE-ON_DVDRW_SOHW-1673S_DEF109FBFA5F-0:0", SYMLINK+="cdrom2", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_SERIAL}=="LITE-ON_DVDRW_SOHW-1673S_DEF109FBFA5F-0:0", SYMLINK+="cdrw2", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_SERIAL}=="LITE-ON_DVDRW_SOHW-1673S_DEF109FBFA5F-0:0", SYMLINK+="dvd2", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_SERIAL}=="LITE-ON_DVDRW_SOHW-1673S_DEF109FBFA5F-0:0", SYMLINK+="dvdrw2", ENV{GENERATED}="1"

But the drive does not get mounted at /dev/cdrom2 or /dev/cdrw2 or /dev/dvd2 or /dev/dvdrw2 or any place else I can see.

Similarly for external hard drives and other usb devices. Any help or advice appreciated!
Last edited by goulo on 2012-02-22 17:15, edited 1 time in total.
goulo
 
Posts: 47
Joined: 2012-01-19 09:52

Re: how to make udev automatically mount devices ?

Postby subhuman » 2012-02-22 12:37

udev does not mount devices, it merely creates what logical devices are appropriate. if you want devices that are connected via usb be mounted automagically, try usbmount:
Code: Select all
apt-get install usbmount
User avatar
subhuman
 
Posts: 358
Joined: 2011-08-20 14:54

Re: how to make udev automatically mount devices ?

Postby goulo » 2012-02-22 17:03

Ah, thanks subhuman. That's the distinction I was missing. I think I am starting to grok it now.

Trying usbmount, I see it automounts the external hard drive and the memory stick (but not CD-ROM drive).

Now trying to get this recognized by PCManFM... that leads me to learning about udisks and possibly devmon. OK, seems I'm back on the trail now. Thanks!

(At the moment I now have udisks attempting to automount external drives and memory sticks and PCManFM noticing this, hurray, but I have the annoying problem of the drives belonging to root, so the mount fails... but that's another issue...)
goulo
 
Posts: 47
Joined: 2012-01-19 09:52

Re: [solved] how to make udev automatically mount devices ?

Postby peter_irich » 2012-02-22 19:57

As I understand, udisks not mounts a mass storage.
You can edit /etc/usbmount/usbmount.conf and and set the desired options in MOUNTPOINTS,
for example "users".
Then edit /etc/udev/usbmount.rules: add MODE="0660" and GROUP="this_group".
For example, if user is in group "users", like in my PC, write GROUP="users".

Peter.
peter_irich
 
Posts: 1268
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: [solved] how to make udev automatically mount devices ?

Postby craigevil » 2012-02-22 20:18

Try installing usbmount.

Also make sure you are in the correct groups and that the line in fstab has user not root.

This is what I have in my fstab:
Code: Select all
/dev/sdb1       /media/sdb1     auto    rw,user


My "groups":
Code: Select all
craig lp cdrom floppy audio dip video plugdev users netdev lpadmin powerdev scanner
Debian Sid KDE Kernel 3.17 Thinkpad R40 Intel M 1.3 CPU 2GB RAM Radeon Mobility 7500
Debian - "If you can't apt-get something, it isn't useful or doesn't exist"
Debian upgrade script smxi | sysinfo script inxi
User avatar
craigevil
 
Posts: 5192
Joined: 2006-09-17 03:17
Location: Oz

Re: [solved] how to make udev automatically mount devices ?

Postby layr » 2012-03-16 07:50

Thanks for mentioning the usbmount package.
I am included in plugdev group, have fstab set up, but still the usb gets mounted as root. So it is writeable only being root. Any easy fixes?
User avatar
layr
 
Posts: 81
Joined: 2011-10-11 15:07

Re: [solved] how to make udev automatically mount devices ?

Postby librefan » 2012-03-19 13:04

Apparently /etc/udev/usbmount.rules no longer exists (at least not in wheezy [testing]) and /etc/usbmount/usbmount.conf stands in its place.

Can we add
Code: Select all
MODE="0660" and GROUP="this_group".
in /etc/usbmount/usbmount.conf like peter_irich said we could in /etc/udev/usbmount.rules?

Cheers
librefan
 
Posts: 12
Joined: 2012-03-19 11:27

Re: [solved] how to make udev automatically mount devices ?

Postby librefan » 2012-03-20 08:30

Hello,

In fact, usbmount is obsolete since the package stopped being maintained in 2007.

So, I installed pmount and edited my fstab and it's almost perfect for me. I'll launch a new thread to describe my small problem.
librefan
 
Posts: 12
Joined: 2012-03-19 11:27


Return to System configuration

Who is online

Users browsing this forum: No registered users and 11 guests

fashionable