LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How does Linux desktop external media mount works? (http://www.linuxquestions.org/questions/linux-desktop-74/how-does-linux-desktop-external-media-mount-works-897475/)

wirawan0 08-15-2011 03:53 PM

How does Linux desktop external media mount works?
 
I notice that in newer distros, external media (USB sticks, external disks, CDROMs) are mounted automatically. How does this work, exactly? I tried to hunt it down to no avail. The reason is this: I recently installed Debian 6 on my laptop, which is fine. But one annoying thing is that the first usb media inserted to the computer will always mount as /media/usb0 , no longer /media/<disklabel> .

Now you may argue that disk label can contain spaces and thus is bad for scripts, but at least it can be consistent. I want to know the following: which program or configuration files determines the mount point name and mount option?

Here's the result of my hunt-down so far (for new enough linux distros):

* udisks (the replacement of HAL) is responsible for dispatching device plug/unplug event so that it is mounted properly. Apparently this is done via d-bus.

* gvfs (under GNOME desktop) seems to be responsible for mounting or dismounting the disk.

But that's the farthest I could get. I see there is gvfsd; but documentation for gvfsd is so *sparse*. If anyone knowledgeable can give me a pointer, I'd appreciate it!

Wirawan

macemoneta 08-15-2011 04:17 PM

You can observe the process by running
Code:

udisks --monitor-detail
and
Code:

dbus-monitor
The desktop (GNOME, KDE, etc.) has a process that connects to dbus. Udisks notifies dbus that the device has been plugged in, which in turn sends a signal to the desktop. The desktop requests from dbus that the device be mounted. When the mount occurs, dbus notifies the desktop, and in response, the desktop launches the media browser (e.g., Nautilus).

wirawan0 08-15-2011 04:35 PM

Can you be more specific for gnome? I know gvfsd is the "brain" of the process, but I have no idea how it works. How it computes mount point name, etc. There is no documentation for it.

macemoneta 08-15-2011 05:31 PM

If you need details beyond the monitor traces, you can strace the process or examine the source. The mountpoint name is always /media/volumelabel. If the media is unlabeled, generic device specific names are used.

frankbell 08-15-2011 09:13 PM

My understanding is that the overall process is handled by udev.

http://www.linux.com/news/hardware/p...ls/180950-udev

wirawan0 08-16-2011 02:14 PM

Quote:

Originally Posted by macemoneta (Post 4443919)
If you need details beyond the monitor traces, you can strace the process or examine the source. The mountpoint name is always /media/volumelabel. If the media is unlabeled, generic device specific names are used.

The mount point location: this does not hold for Debian 6. The first USB storage device inserted will be mounted as /media/usb0 . The subsequent ones will be at /media/<volumelabel> as you say. This is the annoying feature I want to undo, which is why I was asking about the auto-mounting process.

tredegar 08-16-2011 02:21 PM

Quote:

The first USB storage device inserted will be mounted as /media/usb0
Please check your /etc/fstab for any entry referring to /media/usb0
If they are there, please comment them out.
Then (as root) mount -a
Then try again.

wirawan0 08-16-2011 08:47 PM

@tredegar: Thank you! That's the problem. There was an entry of /media/usb0 there! Why did I miss it, I don't know.


All times are GMT -5. The time now is 02:39 PM.