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?


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.

| improve this answer | |
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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