How to reload udev rules without reboot?
# udevadm control --reload-rules && udevadm trigger
Udev uses the inotify mechanism to watch for changes in the rules directory, in both the library and in the local configuration trees (typically located at /lib/udev/rules.d
and /etc/udev/rules.d
). So most of the time you don't need to do anything when you change a rules file.
You only need to notify the udev daemon explicitly if you're doing something unusual, for example if you have a rule that includes files in another directory. Then you can use the usual convention for asking daemons to reload their configuration: send a SIGHUP (pkill -HUP udevd
). Or you can use the udevadm
command: udevadm control --reload-rules
.
However, beware that different versions of udev have historically had different triggers for reloading the rules automatically. So if in doubt, call udevadm control --reload-rules
: it won't do any harm anyway.
The udev rules are only applied when a device is added. If you want to reapply the rules to a device that is already connected, you need to do this explicitly, by calling udevadm trigger
with the right options to match the device(s) whose configuration has changed, e.g. udevadm trigger --attr-match=vendor='Yoyodyne' --attr-match=model='Frobnicator 300'
.
I'm adding this because some day I will need it... again.
Sometimes you get an incorrect matching of ethernet device numbers and MAC addresses. Sometimes this is really important, like when running in a VM and each device is assigned to a different VLAN.
- Bring the network interfaces down, then
- modify
/etc/udev/rules.d/70-persistent-net.rules
(or its equivalent) - re-load with
udevadm control --reload-rules
- re-trigger with
udevadm trigger --attr-match=subsystem=net
- bring the network interfaces up.
I was surprised how well this worked.