Attached is the updated patch following upstream review on PR #2845 (dropped 
redundant libnss_dns.so.* from 11systemd-networkd/module-setup.sh since 
10systemd already installs libnss_*).
From ac7cb7ad3d4b69a1d137e5a005af24b8d6449787 Mon Sep 17 00:00:00 2001
From: Viktor Pashaiev <[email protected]>
Date: Fri, 27 Nov 2026 14:28:43 +0100
Subject: [PATCH] fix(systemd-networkd): populate /etc/resolv.conf and wait for
 online

When 11systemd-networkd is used instead of 35network-manager or
35network-legacy (for example in TEST-61-CHRONY on Debian and Ubuntu),
chronyd in the initramfs fails to resolve pool.ntp.org and
chrony-wait.service times out because:

1. networkd-config.sh does not register an initqueue/finished hook when
   rd.neednet=1 is set, so dracut-initqueue exits immediately when the
   local root device is present without running networkd-run.sh.
2. networkd-run.sh never writes /etc/resolv.conf from kernel command
   line nameserver= arguments or /run/systemd/netif/state DNS= entries
   obtained by systemd-networkd over DHCP.

Register the initqueue/finished check for /tmp/networkd.*.done when
rd.neednet=1 is active, and populate /etc/resolv.conf in
networkd-run.sh if it does not already exist.

Fixes: https://github.com/dracut-ng/dracut/issues/2541
Bug-Debian: https://bugs.debian.org/1155542
Bug-Ubuntu: https://launchpad.net/bugs/2178220
Forwarded: https://github.com/dracut-ng/dracut/pull/2845
---
 modules.d/11systemd-networkd/networkd-config.sh | 2 ++
 modules.d/11systemd-networkd/networkd-run.sh    | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/modules.d/11systemd-networkd/networkd-config.sh b/modules.d/11systemd-networkd/networkd-config.sh
index b6f1ae5..bfdb120 100755
--- a/modules.d/11systemd-networkd/networkd-config.sh
+++ b/modules.d/11systemd-networkd/networkd-config.sh
@@ -38,6 +38,8 @@ if [ -n "$netroot" ] || [ -e /tmp/net.ifaces ]; then
 fi
 
 if getargbool 0 rd.neednet; then
+    # shellcheck disable=SC2016
+    echo 'for i in /tmp/networkd.*.done; do [ -f "$i" ] && exit 0; done; exit 1' > "$hookdir"/initqueue/finished/networkd.sh
     mkdir -p /run/networkd/initrd
     : > /run/networkd/initrd/neednet
 fi
diff --git a/modules.d/11systemd-networkd/networkd-run.sh b/modules.d/11systemd-networkd/networkd-run.sh
index 791b091..e9f1b38 100755
--- a/modules.d/11systemd-networkd/networkd-run.sh
+++ b/modules.d/11systemd-networkd/networkd-run.sh
@@ -74,6 +74,12 @@ for ifpath in /sys/class/net/*; do
             fi
         fi
 
+        if [ ! -e /etc/resolv.conf ] && [ -r /run/systemd/netif/state ]; then
+            for s in $(getargs nameserver) $(sed -n 's/^DNS=//p' /run/systemd/netif/state); do
+                echo "nameserver $s"
+            done > /etc/resolv.conf
+        fi
+
         source_hook initqueue/online "$ifname"
         /sbin/netroot "$ifname"
 
-- 
2.43.0

Reply via email to