Server Fault is a question and answer site for system and network administrators. 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've got a udev rule

ACTION=="add", SUBSYSTEM=="block", KERNEL=="vd[c-z]", ENV{DEVICE_NAME}="KERNEL" RUN+="/usr/local/bin/udevtest"

where devices vd[c-z] trigger the rule and call my script. I am trying to pass the exact name of the device that triggers the script with the $DEVICE_NAME environment variable but it doesn't seem to be being picked up by the called script.

How is this done?

I am trying to write this for Debian and Ubuntu, so I don't think udisks2 can be used.

share|improve this question
up vote 1 down vote accepted

Instead of using an environment variable, can you pass it in to the script as an argument? Something like:

RUN+="/usr/local/bin/udevtest %k"
RUN+="/usr/local/bin/udevtest $KERNEL"

Assuming your script can be modified to handle arguments

share|improve this answer
YES. I should've read man 5 udev, the section that starts with: The NAME, SYMLINK, PROGRAM, OWNER, GROUP, MODE and RUN fields support simple string substitutions. – Andrew Nov 21 '13 at 1:15

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.