Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

#RUNS:
KERNEL=="sd?1", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ff9", SYMLINK+="phone", ACTION=="add", RUN+="/usr/bin/touch /tmp/udev.add"
#DOES NOT RUN:
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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
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. –  Andrew Redd Oct 13 '11 at 15:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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