How does automount / unmount work for USB memory sticks?
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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?
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.
You don't use "noacpi" boot option. This will prevent the HAL and DBUS daemons from running.
The hald and dbusd daemons are running. Look at "ps -u root" to find out.
Monitor the kernel messages with "sudo tail -f /var/log/messages" and then insert the drive. It may indicate what the problem is.
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.
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.
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).
Last edited by pwabrahams; 09-05-2008 at 11:46 PM.
Reason: typo in critical place