From 367166c3232958fb5cfa4beb2555f6055d193c1a Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Wed, 25 Oct 2023 17:18:31 +0100 Subject: [PATCH] preseed_base, ts-host-install: Change NIC NamePolicy to "mac" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit On "italia?" machine, the two network interfaces are competing to have "eno1", base on the "onboard" naming policy. So the name of the network interface can change between "eno1" and "eth0". Switching to "mac" should avoid the unpredictable name based on "onboard" or "slot" policy. The "mac" naming policy break `vif-bridge` for the "vif*.*" network interfaces. So we will avoid the "mac" policy if the driver is "vif". This also have an impact on guest created with ./ts-debian-install, as they use the initrd from dom0, so the interface in the guest will be renamed according to default policy (which rename eth0 to enX0). Signed-off-by: Anthony PERARD Acked-by: Roger Pau Monné --- Osstest/Debian.pm | 22 ++++++++++++++++++++++ ts-host-install | 16 ++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index 102b024..31d32d6 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -962,6 +962,28 @@ cp /$RULESDIR/70-persistent-*.rules /target/$RULESDIR 2>/dev/null || true END + if ($ho->{Suite} !~ m/lenny|squeeze|wheezy|jessie|stretch|buster/) { + # Always use MAC address in network interface names. + # + # But keep the default policy if the driver is "vif", which match the + # "vif$domid.$idx" interface in dom0, and the interface in domU. This file + # is going to be added to dom0's initrd, which is used by some guests + # (created with ts-debian-install). + preseed_hook_installscript($ho, $sfx, + '/usr/lib/base-installer.d/', '05ifnamepolicy', <<'END'); +#!/bin/sh -e +linkfile=/target/etc/systemd/network/90-eth-mac-policy.link +mkdir -p `dirname $linkfile` +cat > $linkfile <{Suite} !~ m/lenny|squeeze|wheezy|jessie|stretch|buster/) { + # Switch to more predictale nic name based on mac address, instead of the + # policy "onboard" which can try to set the same name ("eno1") to two + # differents nic, or "slot". New names are "enx$mac". + system_checked(qw(mkdir -p --), "$initrd_overlay.d/lib/systemd/network"); + file_simple_write_contents + ("$initrd_overlay.d/lib/systemd/network/90-eth-mac-policy.link", + <