Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
The Wikipedia page on udev is a pretty good place for an overview... – jasonwryan Oct 19 '12 at 7:04
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.