1

Here is a simple rule I created in /etc/udev/rules.d/21-persistent-local.rules for my Seagate 500 GB expansion drive which uses a USB interface on a Debian machine running inside a VM.

ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{ID_SERIAL_SHORT}=="NA453QQS", SUBSYSTEM=="usb", HOTPLUG == 1, \
RUN+="/usr/local/bin/run.sh"

After saving this, I run I run udevadm trigger. Finally, I plug in my drive and run udevadm monitor --env to verify if expansion drive is correctly loaded which is indeed the case.

Now I define the rule that on the add action, run.sh should run. run.sh has nothing except two sudo insmod foo.ko and sudo rmmod foo.ko. But the script fails to run. Concretely, nothing is printed in dmesg against the script run.sh. The module I load in the kernel prints messages which should be visible when exiting and entering the kernel.

What can be the possible reason for this problem?

P.S.: In the above rules file, I used both of these against the ATTRS{...} ID_SERIAL=Seagate_Expansion_NA453QQS ID_SERIAL_SHORT=NA453QQS

  • 1
    Why are you attempting to use sudo? – jasonwryan Sep 21 '14 at 18:08
  • If I'm not mistaken, it should be ATTR rather than ATTRS. – peterph Sep 21 '14 at 18:19
  • Try changing the SUBSYSTEM to block, not usb. This is common mistake. Also the right DEVTYPE may be disk not usb_device. You may also be interested how to narrow to usb, that will be ENV{ID_BUS}=="usb" :-) Cheers. – Scyld de Fraud Sep 21 '14 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.