Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

How should I specify the "start on" condition to run an upstart script when a device (an external disk) is attached?

share|improve this question
up vote 0 down vote accepted

Yes. Have a read of man upstart-udev-bridge. Basically anything that can trigger a udev script can trigger an Upstart event. There's more in the Upstart Cookbook's Bridges section.

In your case, we're talking about a block device so here's an example from a StackOverflow post by deft_code:

start on block-device-added


   if [ `blkid $DEV` -eq "YOUR-THUMBDRIVES-UUID" ]; then
      /home/you/bin/thumbdrive_special $DEV
end script

The other route is just using udev to trigger run a script when you plug something in. That could be anything, including running a upstart command.

Upstart has a mounted event but this only comes off the back of the booting mountall call. I don't think it's any use here.

share|improve this answer
Is the event trigger if I attach a lopp device (losetup /dev/loop0 backedfile.raw)? – Skarab Sep 19 '13 at 21:54
I honestly don't know what events that would trigger. You could investigate with udevadm. – Oli Sep 20 '13 at 7:27

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.