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 interested in running an rsync script whenever any new volume is mounted on my Debian box. What are some potential triggers / strategies for listening for a new volume mount?

share|improve this question
up vote 6 down vote accepted

You can create a new rule to /etc/udev/rules.d/. First read the file /etc/udev/rules.d/README. In the new rule file, add something like


(I did not try the above line, try your own rules.)

Note that the script will be run as root. You might want to use su to change that.

Using ACTION=="add" would require script.sh first to mount the volume.

share|improve this answer
This catches the case when the volume is attached, but not the mount. A mount might not necessarily occur when it's attached. – Marco Sep 6 '12 at 12:16
Marco, correct. I edited the ACTION from add to mount. I still cannot test the rule, so please be careful with that. Also SUBSYSTEM=="block"might be more useful than KERNEL. – Jari Laamanen Sep 6 '12 at 12:47

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.