[lfs-dev] Persistent Net Rules in Systemd Udev are not working.

Bruce Dubbs bruce.dubbs at gmail.com
Tue Jul 24 22:48:55 PDT 2012

Bryan Kadzban wrote:
> Bruce Dubbs wrote:
>> Bryan Kadzban wrote:
>>> Bruce Dubbs wrote:
>>>> Armin K. wrote:
>>>>> Bruce, some guy came on the irc saying that network rules creation
>>>>> does not work in systemd extracted udev.
>>>>> <Zenther> working my way through the cvs book and get to 7.2.1.
>>>>> Creating stable names for network interfaces and I am getting a
>>>>> cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or
>>>>> directory. Above that I see it list out my eth0 and wlan0.
>>>>> Can you check and/or confirm that?
>>>> I can confirm that in chroot.  I think he is referring to section
>>>> 7.5. That needs to be changed.  The 'udevadm test' command no longer
>>>> runs aux programs, e.g. /lib/udev/write_net_rules.
>>>> However, the first time the system is booted, udevd will run the
>>>> rules and the 70-persistent-net.rules file will be written at that
>>>> time.
>>> Well, they finally killed it.
>> Yes, but we can fix that.  In the udev-lfs tarball we have the needed files:
>> write_net_rules
>> rule_generator.functions
>> We need to change two places in rule_generator.functions where it has
>> RUNDIR=$(udevadm info --run) with a constant RUNDIR=/run/udev
>> Then in section 7.2 (inside chroot), we need to do a couple of things:
>> cd ~
>> mkdir -p /run/udev
>> cat set_persistent_net_rules.sh  << EOF
>> #! /bin/bash
>> for NIC in /sys/class/net/eth* ; do
>>      IF=${NIC##*/}
>>      if [ "$IF" == "eth*" ]; then break; fi
>>      export INTERFACE="$IF"
>>      export MATCHADDR="$(cat $NIC/address)"
>>      export MATCHDEVID="$(cat $NIC/dev_id)"
>>      export MATCHIFTYPE="$(cat $NIC/type)"
>>      /lib/udev/write_net_rules
> ...And /etc is writable here, so I think this should generate something
> usable at least.  (Might need a couple more environment vars for stuff
> like the vendor/device ID and the driver, but whatever.)
> I think we used to do it this way, actually.  :-)
> One problem (I think) is that this won't follow the whitelist/blacklist
> rules in the existing 75-persistent-net-generator.rules file.  So it'll
> try to generate rules for NICs that are known to be buggy (locally
> administered MACs that change per boot, qemu-created devices that change
> MACs at every boot, etc.).  :-/

Thanks for pointing that out.  I guess I can convert the 75-rules to a 
script and add it to the udev-lfs tarball and incorporate the other net 
rules there too.  Then in Chapter 7 we will only have to run it.

>> We need to be careful that someone doesn't remove /run/udev after
>> booting or outside of chroot.
> Hmm?
> Oh, the rm -rf.  Can we make it a tmpfs in chapter 7, and fix it that
> way?  Then we don't need the rm in the instructions; it just needs to be
> unmounted at shutdown time.  :-)

I actually thought of that first, but wasn't sure how things would work 
if someone exited chroot without umounting first.

> (I still like the idea of indirection in the network bootscripts; it
> seems to match how udev handles storage, input, and sound devices, much
> better.  If I get some time this week or weekend or something, I'll
> replace my network scripts with whatever is current in the book -- I'm
> still using really old stuff since this system is pretty old -- and
> assuming that works, I'll look into adding the indirection, then see how
> I like the results.)

OK.  I'll be interested in what you come up with.

   -- Bruce

More information about the lfs-dev mailing list