[systemd-devel] udev event on usb unpluged

christophe.jalady at free.fr christophe.jalady at free.fr
Tue Aug 25 13:17:02 PDT 2015


Hi,

I would like to receive an event (actually run a script) when I plug/unplugged an usb cable.
I tried to use udev with this simple rule:
SUBSYSTEM=="usb",RUN+="/var/local/usb-changed.sh"

I do receive the "add" event when I plug the usb cable: just perfect !

But I never receive the "remove" event. 
Any idea why ?

More information:
I use linux kernel v3.16.
When the cable is plugged, I load the kernel module "g_mass_storage", this work great. My need is to unload the module when the usb cable is unplugged (note it would be even better if I receive an event when the mass-storage is unmounted by the other host, but I do not have any idea where to look for.)

Thanks by advance for any hint.

Christophe


More information about the systemd-devel mailing list