I'm running a Ubuntu system where USB drives are mounted automatically.
I'm curious to what happens when a USB device plugs in a port. Which part of the linux senses that a new device has been plugged in? After that which processes (and what is the caller or callers) are called to mount it to the system? Are theese kernel-space, user-space processes or mixed ?

I'd like to follow theese steps in a C/C++ program. Is there any way to do that? Where could I read more about it? How would you do it?

  • 1
    The Wikipedia page on udev is a pretty good place for an overview...
    – jasonwryan
    Oct 19, 2012 at 7:04

1 Answer 1


As far as I know, there are several systems that can be used to react to a plugged-in USB device. One is udev, and this runs as root. You can put your own rules and scripts in /etc/udev/rules.d.

Furthermore, the desktop environments all implement some automounting, see for example this guide. See also the answer to this question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .