I've followed tutorials to make this happen, but I've failed. My system is Ubuntu 14.04 with kernel 3.18.0-031800-generic. I've searched for udev rule keys using udevadm monitor --env. Its output generated by rmmod module_name was

KERNEL[202.017039] remove /module/module_name (module)

UDEV [202.018837] remove /module/module_name (module)

So I've created scripts (and marked them as executable for all) to create and remove node:

$ cat /usr/share/another_folder/make_node.sh
mknod /dev/device_name c 89 1

$ cat /usr/share/another_folder/rm_node.sh
rm /dev/device_name

And udev rule that uses them:

$ cat /etc/udev/rules.d/89-the-name.rules
SUBSYSTEM=="module", DEVPATH=="/module/module_name", ACTION=="add", RUN+="/usr/share/another_folder/make_node.sh"

SUBSYSTEM=="module", DEVPATH=="/module/module_name", ACTION=="remove", RUN+="/usr/share/another_folder/rm_node.sh"

...but it doesn't work when I lo (even after restarting udev or rebooting system). dmesg doesn't show anything about the case:

$ dmesg |grep udev
[    0.928948] systemd-udevd[121]: starting version 204    
[    5.155707] systemd-udevd[316]: starting version 204

What am I missing?


To see what happens you can run

sudo udevadm monitor

in one terminal and then trigger the wanted event with

sudo udevadm trigger --action=add --subsystem-match=module

The monitor will show the events seen by udev.

Your problem is probably that in your scripts mknod and rm are not found as no PATH is set by udev. Use absolute pathnames or set a PATH at the start of the scripts.

| improve this answer | |

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.