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 <<EOF
+[Match]
+Type=ether
+Driver=!vif
+[Link]
+NamePolicy=mac
+EOF
+END
+ }
+
debian_overlays($ho, sub {
my ($srcdir, $tfilename) = @_;
preseed_hook_overlay($ho, $sfx, $srcdir, $tfilename);
print CANARY "\n# - canary - came via initramfs\n" or die $!;
close CANARY or die $!;
+ if ($ho->{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",
+ <<END);
+[Match]
+Type=ether
+Driver=!vif
+[Link]
+NamePolicy=mac
+END
+ }
+
my %xopts;
di_special_kernel($ho, sub {