Interesting, but why don't you use a udev rule?<p>Something like KERNEL=="sdg", RUN+="/usr/bin/madagascar"
and then you have madagascar check the environment variable ACTION for a 'remove', and when you see that run shutdown? (or just write straight into sysreq for instant poweroff)