Linux – How to regenerate 70-persistent-net.rules without reboot

linuxudev

The file /etc/udev/rules.d/70-persistent-net.rules is auto-generated on a Linux system with udev, if it does not exist, during reboot. But I would like to know how to create this rules file (with a command) without rebooting the server.

I was Googling around for a while and found that the rules file is generated by this script:

/lib/udev/write_net_rules

However, it is impossible to run this script from command line, since (I assume) it wants to be started by udev, with some environment variables set properly. Starting it manually prints error message "missing $INTERFACE". Even if I set env variable INTERFACE=eth0 prior the starting of the script, it still prints error "missing valid match". Not to mention I have two interfaces (eth0 and eth1) and I want the rules file generated for both.

I was also thinking to trigger udev events like this, hoping it will start the script from udev itself, but nothing changes:

udevadm trigger --type=devices --action=change

So, does anybody know how to regenerate the persistent net rules in file /etc/udev/rules.d/70-persistent-net.rules without reboot?

Best Answer

According to man page --action=change is the default value for udevadm.

   -c, --action=ACTION
       Type of event to be triggered. The default value is change.

Therefore you better try --action=add instead. It should help:

/sbin/udevadm trigger --type=devices --action=add
Related Question