You are not logged in.
Hi,
I'm wanting to run a script automatically when a particular USB storage device is mounted. I've looked at the udev rules and utilities from the systemd-tools package, and while that can detect when a device is connected, is does not seem to detect when it is mounted on the file system (two different things). Similarly, using inotifywait to look for a particular file on the USB storage doesn't seem to work as it loses track when the device is unmounted then remounted.
Any ideas?
E.
Offline
How do you mount the USB? Couldn't whatever you use to mount also trigger the script?
Also, instead of looking for a file on the USB, can't you use inotify to watch the mountpoint? (eg, watch /media/ directory, when it changes, get the contents and check for your device).
Last edited by Trilby (2012-06-15 02:34:07)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
It is usually being mounted by the Calibre ebook manager. It does not have a facility to trigger a script when it mounts a device.
However, the inotifywait on the /media folder works. Not sure why I didn't think of that, I was too focused on watching the /media/device folder I guess. :-)
Thanks.
E.
Offline