-   Linux - Hardware (
-   -   How does automount / unmount work for USB memory sticks? (

pwabrahams 09-01-2008 10:18 PM

How does automount / unmount work for USB memory sticks?
I'm running Kubuntu Hardy Heron 8.04 and I'm having trouble with getting my USB memory sticks to mount automatically when I insert them and unmount automatically when I remove them. I'd have more hope of fixing the problem if I understood what software components are involved in the process, but I haven't been able to locate an explanation of that. Where can I learn about how automounting works?

MS3FGX 09-01-2008 10:29 PM

Automatic mounting in modern distributions makes use of the HAL and UDEV systems. HAL is an abstraction layer which notifies the system as to what devices have been connected and disconnected. UDEV is a system designed to automate the creation and removal of devices nodes (the files under /dev) which are required to address devices under Linux.

These two systems work in conjunction with your desktop environment to automount new devices. It is important to understand that HAL and UDEV themselves do not actually mount devices, or access them at all. It is up to your desktop environment to pull it all together. In other words, your DE is going to listen for HAL events, and then go ahead and mount the device with the device node created by UDEV. If your desktop environment is not built to support this (for example, FluxBox) it doesn't matter if HAL and UDEV are working, nothing is going to happen. In that case you would need a stand-alone HAL event manager like ivman.

Now, presumably, you are running KDE. KDE is HAL-aware, so the problem isn't a lack of support in your environment. It could be a permissions issue, or the HAL daemons might not be running. It probably isn't a UDEV problem, as you would likely have more issues than just USB mounting if UDEV wasn't functioning properly. Of course it is impossible to say for sure without more details on the problem you are having.

jschiwal 09-01-2008 10:45 PM

There are four quick things to check.
  1. You don't use "noacpi" boot option. This will prevent the HAL and DBUS daemons from running.
  2. The hald and dbusd daemons are running. Look at "ps -u root" to find out.
  3. Monitor the kernel messages with "sudo tail -f /var/log/messages" and then insert the drive. It may indicate what the problem is.
  4. Check the filesystem on the pendrive. Can you mount it manually?

Which "callout" that HAL uses when you insert the disk depends on the desktop environment you use. You might want to indicate which desktop you use. KDE has a service that runs in the background listening for messages from the hal daemon.

Also, if the drive is listed in /etc/fstab, hal won't mount it automatically.

Another thing to check is the hidden files in /media/.

There are two files, .hal-mtab and .hal-mtab-lock. A stale entry might also cause a problem. Eject all external media and the delete these files if they don't disappear.

If when monitoring /var/log/messages, the device node of the partition is given, you could try mounting it with the halmount command. It is udev that creates the device node. If a device node is working, then udev must be working.

For example: "halmount /dev/sdb1"

It might also help if you posted the output of "sudo /sbin/chkconfig -l".

If you use kde 3.5, then enable the display of unmounted and mounted external drives in desktop properties.

pwabrahams 09-02-2008 11:44 AM

Explicit mount works
A big clue to what's going on is that I can mount the USB drive explicitly with, e.g., mount /dev/sdb1 /media/usb1. So if HAL and UDEV are required for an explicit mount, they can't be at fault.

hald isn't running, I found. If I try to start it explicitly, nothing happens -- it doesn't show up in the process list, but there are no messages about it either in /var/log/messages or in the output of dmesg.

I'm running KDE 3.5.10.

MS3FGX 09-02-2008 12:10 PM


So if HAL and UDEV are required for an explicit mount, they can't be at fault.
They aren't, at least, HAL isn't. The fact that you have a /dev/sdb device node when you plug the device in would seem to indicate that UDEV is working.

Combined with the other clue you found, I would say HAL probably isn't working properly. Have you tried reinstalling it?

pwabrahams 09-02-2008 12:27 PM

hal reinstallation fails!
I tried reinstalling hal and got the message:

subprocess post-installation script returned error exit status 1
Where do I go from here?

I guess hal isn't working right.

pwabrahams 09-05-2008 04:05 PM

Hal working now, but still no automount notification
I finally got hal working again -- the problem was an improperly designed configuration file in /etc/dbus-1/system.d/hal.conf (contradictory permissions). I can get automounting by installing usbmount, so that /dev/sdb1 is correctly mounted on /media/usb0. However, there is no desktop notification that the mount has taken place. That's not too surprising since usbmount is advertised as a lightweight solution to the automount problem.

Without usbmount, when I insert a USB memory stick into the machine, hal definitely knows about it since it shows up in the lshal listing. However, it isn't automounted.

So I'm still wondering which system component is supposed to pick up on the mount and issue the notification. Whatever it is, it's falling down on the job (and pre-Hardy, it was working).

All times are GMT -5. The time now is 10:21 AM.