Ubuntu: disable udev's persistent-net-generator.rules
I'm using Ubuntu 12.04 LTS server edition and I am modifying /etc/udev/rules.d/70-persistent-net.rules
to define my own mappings of ethernet interfaces to MAC addresses; that file is initially generated by rules in /lib/udev/rules.d/75-persistent-net-generator.rules
at system installation time (or at the first boot, I actually don't know and it doesn't matter here).
How can I be sure that my edited version will never ever be overwritten by anything?
Removing the persistent-net-generator, as suggested on some websites, is not the Right Thing™ to do as told by comments in the file itself: it will be overwritten by any update of the udev
package. I'm looking for a more formally correct way to disable it.
Is it enough to just make sure that /etc/udev/rules.d/70-persistent-net.rules
does exist?
Maybe there are other events that could trigger its regeneration? (eg. adding or removing ethernet interfaces to the system?)
Solution 1:
The correct way to disable the generator is to override it with an empty file. Any rules in /etc/udev/rules.d
will take precedence over rules in /lib/udev/rules.d
, so simply create an empty file or symlink to /dev/null
:
sudo touch /etc/udev/rules.d/75-persistent-net-generator.rules
-OR-
sudo ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
This is safe and future-proof.
Solution 2:
You should take a look on this file: /etc/udev/rules.d/README
Then you can read, that your own udev rules file should have higher number in its name, than the 75-persistent-net-generator.rules
. So create a new rules file named like /etc/udev/rules.d/76-persistent-net.rules
with your own settings.