I have two rules one for when a device, my phone, is connected and one for when it is disconnected. The rule for add runs the remove rule does not. Here is my udev rule. I simplified but the remove event does not run.

KERNEL=="sd?1", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", SYMLINK+="phone", ACTION=="add", RUN+="/usr/bin/touch /tmp/udev.add"
KERNEL=="sd?1", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", SYMLINK+="phone", ACTION=="remove", RUN+="/usr/bin/touch /tmp/udev.remove"

Why would one run but not the other?


You will need to refactor your removal rule as outlined here: http://www.linuxquestions.org/questions/linux-desktop-74/udev-not-doing-remove-rules-841733/

Summarizing the link content, it appears that once a device is removed, some of its attributes are not readable anymore so you will have to monitor the device removal and focus on the attributes that are dumped with udevadm monitor --environment --udev.

Also, creating a symlink during removal is plain wrong.

  • 2
    Silly copy and paste errors. That was it. It t should also note that the filtering is on environment variables with ENV{VAR}== instead of the ATTRS{VAR}== and the command above is how you can get the environment variables to filter on. Thank you. Oct 13 '11 at 15:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.