You are not logged in.
Hi,
I'm trying to set up automount of removable devices using udev.
I am following the [wiki]udev[/wiki] wiki page and automounting works great for USB devices and SD cards but I can't get the CD/DVD automounting to work.
This is the rule that I'm using (taken from the wiki):
/etc/udev/rules.s/11-automount-cds.rules
KERNEL!="sr[0-9]*", GOTO="disc_by_label_auto_mount_end"
# Get label
ACTION=="add", PROGRAM=="/sbin/blkid -o value -s LABEL %E{device}", ENV{dir_name}="%c"
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'", RUN+="/bin/mount -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
ACTION=="add", RUN+="/bin/ln -s /media/%E{dir_name} /media/disc"
ACTION=="remove", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"
LABEL="disc_by_label_auto_mount_end"
KERNEL!="sr[0-9]*", GOTO="disc_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}="%k"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount /dev/%k /media/%E{dir_name}"
ACTION=="add", RUN+="/bin/ln -s /media/%E{dir_name} /media/disc"
# 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="disc_by_label_auto_mount_end"
I guess there must be some error in the rule, but I can't find it.
Could someone please help me to understand what's wrong here? Any help is greatly appreciated.
Thank you!
Last edited by rent0n (2010-07-03 19:04:31)
rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686
Offline
First off, is it normal to have two KERNEL lines and pointing to two LABEL lines with the same label? From what I've understood there should be only one of the KERNEL-LABEL blocks. Maybe it is a mistake in the wiki and it should be corrected.
Offline
I would like to know about this too.
In some places I read that udev rules can't work for cd/dvd drives in the same way as usb hdd/pendrives because they require constant polling or something. But in other places - including our esteemed wiki - I read about udev rules that can automount cd/dvds.
I have also had problems trying to get cd automounting to work using the rules in the wiki. Yet the conflicting things I have read make me unsure whether its even possible to automount cds just using udev rules.
Any udev masters know the truth?
Offline
From what I've read so far, udev does poll for changes, as well as insert/remove devices. This can be confirmed by executing:
sudo udevadm control --log-priority=debug
inserting/removing disks and monitoring /var/log/messages.log output. My guess is maybe the matching ACTION=='add' may be the culprit, but I have not yet found a solution/workaround.
Offline
I guess there's something more.
I renamed /etc/udev/rules.d/75-cd-aliases-generator.rules.optional in 75-cd-aliases-generator.rules. This in turn resulted in the creation of another file: 70-persistent-cd.rules.
Now, when I insert a cd, it makes some noise, like if it gets mounted (I can't remember this noise before, can you confirm?), but I can't see anything in /media or /mnt.
How can cd automounting be so difficult?
rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686
Offline
Any news on that? I couldn't get the auto mount with udev work either.
Sorry for my English. Feel free to point out my errors.
Offline
Too bad that no one is able to help us.
I guess this is probably an Udev bug or limit rather than a problem in the rule posted above.
I'm officially looking for alternatives, now.
Basically I would need an easy way to automount USB sticks, USB hard drives, CDs, DVDs, SD cards...
So, what do Archers use to accomplish this sort of things?
[Maybe it would be better to start another thread for this, but let's see where this one goes...]
Last edited by rent0n (2010-07-05 19:41:13)
rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686
Offline
Had the same problems - if your're looking for an easy way: start hal an dbus (in rc.conf demaon section dbus before hal) - hal is working perfect for me ..
Archlinux on Samsung x20 notebook and on Acer Aspire One 110l
Offline
Had the same problems - if your're looking for an easy way: start hal an dbus (in rc.conf demaon section dbus before hal) - hal is working perfect for me ..
But what applications are you using? xorg itself no longer uses hal. I believe some applications such as Thunar still use hal as does KDE (or some parts of it).
All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.
Offline
Had the same problems - if your're looking for an easy way: start hal an dbus (in rc.conf demaon section dbus before hal) - hal is working perfect for me ..
rent0n asks not about hal (hal is the past). As I understand the question is - if it is possible with pure udev. But being honest I haven't heard about udev and polling. I also looked through
sudo udevadm monitor
but there is no sign of activity during or after CD insert. But it would be great feature to have udev working with CD/DVDs
Last edited by nbvcxz (2010-07-06 15:13:55)
Lenovo G50 | LXQT-git | compton | conky
Offline
The udev daemon udevd(8) receives device uevents directly from the kernel whenever a device is added or removed from the system, OR IT CHANGES ITS STATE.
I guess this can be assumed to be "polling". Also by setting "sudo udevadm control --log-priority=debug" and inserting a disk gives this in /var/log/messages.log. So there is activity when a cd is inserted. I just did not find the time yet to troubleshoot this, but when I have an answer I will post back.
The rule I use is a slightly clipped/altered version of the wiki rule
# NOTE: INCOMPLETE AND NOT WORKING YET
KERNEL!="sr0", GOTO="disc_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}="%k"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount /dev/%k /media/%E{dir_name}"
ACTION=="add", RUN+="/bin/ln -s /media/%E{dir_name} /media/disc"
# 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="disc_by_label_auto_mount_end"
Last edited by tzervo (2010-07-06 15:40:02)
Offline