Ubuntu Hardy : Testing for environment variables in udev rules doesn't seem to work

Posted by Fred on Server Fault See other posts from Server Fault or by Fred
Published on 2011-01-26T21:42:06Z Indexed on 2012/03/30 5:32 UTC
Read the original article Hit count: 501

Filed under:
|

I have a Ubuntu 8.04 LTS (server edition), and I need to write a udev rule for it to act upon plugging a USB thumb drive. However, I need a different action depending on the filesystem of the drive. I know I can use the ID_FS_TYPE environment variable to check for the filesystem on the drive.

Following instructions found here, I try a dummy udev rule as such :

KERNEL!="sd[a-z][0-9]", GOTO="my_udev_rule_end"
ACTION=="add", RUN+="/usr/bin/touch /tmp/test_udev_%E{ID_FS_TYPE}"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/usr/bin/touch /tmp/test_udev_it_works"
LABEL="my_udev_rule_end"

However, when I plug in a thumb drive with a vfat filesystem (which should trigger both rules), I end up with a file called /tmp/test_udev_vfat, meaning the first rule was triggered successfully, and that the ID_FS_TYPE environment variable is "vfat", but I don't have the other file, meaning that although I know the ID_FS_TYPE env variable is "vfat", I can't seem to check against it for a match.

I tried googling the thing, but pretty much every result seems to assume ENV{ID_FS_TYPE}=="vfat" works. I also tested the exact same udev rule on Ubuntu 10.04 LTS server, and I have the same result.

I'm probably missing something very simple, but I just don't get it. Does anyone see what is wrong with my udev rule that would prevent it from matching on ENV{ID_FS_TYPE}?

Thanks.

© Server Fault or respective owner

Related posts about udev

Related posts about udevd