Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

You will need to refactor your removal rule as outlined here:

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
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


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.