Today I have released uam-0.2. The new release adds a long-awaited feature — capability of mounting and unmounting ejectable media like CD and DVD disks. And it does so in a way much simpler than I expected.
But first, what is uam?
uam is my old project, dating back to the times of HAL. Although HAL is long gone, uam is still there shining. It is a simple, lightweight media automounter using udev rules only.
Unlike HAL (or udisks) it doesn’t introduce any additional daemons. It just installs a few udev rules and helper scripts. When a media device is added or removed, udev calls the scripts and they perform all the mount/umount operations as necessary. HAL/udisks not required anymore, neither do mounter daemons.
Isn’t that a very limited solution?
Of course uam can’t be as flexible as the HAL/udisks attempt. You can’t get it (easily) to do things like asking user for permission or password; well, it doesn’t even create mounted media icons on your desktop. But is that what you really want it to do?
You can tell uam is one of the plug & play apps. emerge uam, CR and newly-inserted media shall start appearing in /media
. There’s a config file too. If you want to fine-tune it a little, there are a few more switches and options in /etc/udev/uam.conf
. You can set mount options, mountpoint naming, device filtering…
But how does it handle CDs and DVDs without a daemon?
Before, it wasn’t possible to mount CDs without some kind of a polling daemon. HAL/udisks provided such a daemon; I was even considering adding such a daemon to uam. The other solution was to use sys-apps/pmount
which allows unprivileged users to mount removable media.
None of these is any longer necessary. Nowadays, kernel can poll ejectable drives itself and report media change (and eject) events through udev. As of 0.2, uam handles those events and is able to mount CDs as well.
In order to do that, the kernel polling has to be enabled. This can be done either per-device:
echo 5000 > /sys/block/sr0/events_poll_msecs
or by setting a common polling interval as events_dfl_poll_msecs
parameter to the block
module:
echo 5000 > /sys/module/block/parameters/events_dfl_poll_msecs
The interval is specified in milliseconds, i.e. the above examples set it to 5 seconds. Smaller intervals result in a quicker mounting of CDs, larger result in less polling overhead.
Great news! Not that I’m mounting CDs all the time, but nevertheless.
But what kernel version did introduce this feature? And is there any way to set polling interval permanently (not losing it after reboot)? Some kind of `/etc/sysctl.conf`. Apart from `/etc/local.d/uam` with that very `echo` you mentioned, of course
I’m not aware of the exact kernel version. A quick bisect on #gentoo-dev shows that 2.6.38 certainly has it, and 2.6.36 certainly doesn’t :P.
About setting it permanently, it’s just a module option. If you have
block
as a module, you can simply usemodprobe.d
. Otherwise, I think you can pass it on the kernel command-line. I’ll try that in a while.Ok, I’ve got better answers for you. The kernel version is 2.6.38, and the argument to kernel command line would be:
block.events_dfl_poll_msecs=5000
Great, thanks for research
I reckon it’d make way into README.
And another request: could you please describe what’s to be done to mount NTFS volumes with ntfs-3g? I remember it wasn’t that obvious. If you want, I could contribute those changes via GitHub myself (though I’m not sure ntfs-3g tip turned out to be good’n’proper)
Kernel stuff is in README now.
For ntfs-3g, there’s a commented out line in
uam.conf
. I’d appreciate if you could tell me whether it (still) works.I don’t think so. At least it did not work a month ago, when I tried. I’ll try to grab some NTFS volume to try, but at the moment I have the following to make it work:
MOUNT_OPTS_NTFS="${MOUNT_OPTS_VFAT} -t ntfs-3g"
MOUNT_OPTS_NTFSG="${MOUNT_OPTS_NTFS},force -t ntfs-3g"
The second line seems to be vital.
That
NTFSG
seems weird to me. Could you enable traces and pastebin/send me a trace when mounting such a volume?Thanks for concern, Michał. I’ve just get such a device and reported an issue on GH: https://github.com/mgorny/uam/issues/6
Is uam capable of mounting a device under an user-specified name? e.g. can I list a mapping from, say, serial numbers to human-readable names and the latter would appear in /media when uam mounts it?
Not explicitly ATM but it seems like a good idea to add that. I’ll think how to implement it.
In the meantime, there are two possible solutions. The simpler one is setting up the mount point in /etc/fstab but in this case uam won’t add its mount options (e.g. you will need to set permissions in fstab and so on) and the mountpoint would have to exist before mounting (i.e. /media can’t be on tmpfs).
The other solution is to set up a conditional addition of plain name to
MOUNTPOINT_TEMPLATES
(it is a plain shell script). Such an addition would look like:(it should be added below normal MOUNTPOINT_TEMPLATES)
hey what happened to uam? getting 404 error over on github :(
hope you still check these comments
It has been moved to bitbucket along with my other projects. I have updated the links in the post.