6

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?)

10

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.

  • It's probably better to just touch an empty file. – mgorven Mar 7 '13 at 17:50
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.

  • No such file exists on Debian 8.2, so it must not be a reliable source. Anyway, won't this cause both files to be invoked? AFAIK in such situations, both files must have exactly the same name in order to invoke precedence/masking, and leading numbers are considered a different that prevents masking. – underscore_d Nov 4 '15 at 0:03
-1

Additional cents for presenting this rule from being re- generated in a batch. Usually I use this at our DevOps practice

for i in `cat /tmp/allnode.lst | awk '{print $1}'`; do echo $i; \
ssh $i 'mv /lib/udev/rules.d/75-persistent-net-generator.rules /tmp/'; done

Col 1 in allnode.lst is IP address

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.