Not-so-predictable network names

Ian Kelling ian at iankelling.org
Thu Feb 9 23:17:37 CET 2017


On Wed, Aug 10, 2016, at 01:56 AM, Ian Kelling wrote:
> On Tue, Aug 9, 2016, at 07:38 PM, andrew bezella wrote:
> > On Tue, 2016-08-09 at 14:12 -0700, Ian Kelling wrote:
> > > 
> > > Yes, I'm following this path. At the top of 30-interface, I have a
> > > condition
> > > for if the os is in a class that uses a persistent name, and inside
> > > I have this code:
> > 
> > [...]
> > 
> > oh! i like that solution, thanks for sharing...
> > 
> > -- 
> > andrew bezella <abezella at archive.org>
> > Internet Archive
> 
> Thanks. Some of the long lines got wrapped in the mail.
> Not sure if it was my client or the list, but here it is again
> with shorter lines that hopefully do not get wrapped:
> 
> for field in ID_NET_NAME_FROM_DATABASE \
>                  ID_NET_NAME_ONBOARD \
>                  ID_NET_NAME_SLOT \
>                  ID_NET_NAME_PATH \
>                  ID_NET_NAME_MAC; do
>     name=$(udevadm info /sys/class/net/$NIC1 | \
>                sed -rn "s/^E: $field=(.+)/\1/p")
>     if [[ $name ]]; then
>         NIC1=$name
>         break
>     fi
> done
> if [[ ! $name ]]; then
>     echo "$0: error: could not find systemd predictable network name"
>     exit 1
> fi

Fyi: Thomas now has a very good and more correct script than this in the
example config's 30-interface. One issue I had is that it won't detect
the new name when installing a kvm vm using a jessie based nfsroot.  It
will work using a stretch one, and it has worked for me on physical
machines. This is a limitation of the udev/kernel/something version in
jessie. If you don't want to update to stretch nfsroot yet (which seems
to work fine btw), but still want to install stretch vms, here is a
workaround:

in 30-interface, just before the error condition which currently says
"if [[ ! $name ]]; then", at the end of the newnicnames function,
insert:

if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
    NIC1=ens3
    return
fi

The conditions checks that that the mac is in the libvirt range.

Another thing to remember, if you update to a stretch nfsroot, the
default
basefile will be stretch, so to install jessie and not rely on the
default basefile, you need to for example wget
http://fai-project.org/download/basefiles/JESSIE64.tar.xz into the
basefile directory and set the class JESSIE64.


More information about the linux-fai mailing list