Attached is the simplified 10-line patch matching upstream PR https://github.com/dracut-ng/dracut/pull/2845 (without the extra unit test harness in test/TEST-61-CHRONY/test.sh).
From 0ed127da5a3e10fb7dcec3d883a5ca34f28ff074 Mon Sep 17 00:00:00 2001 From: Viktor Pashaiev <[email protected]> Date: Fri, 27 Nov 2026 13:49:49 +0100 Subject: [PATCH] fix(systemd-networkd): populate /etc/resolv.conf and wait for online
On distributions where dracut-network defaults to 11systemd-networkd, the 61-chrony test times out in chrony-wait.service because: 1. module-setup.sh does not install libnss_dns.so.* into the initramfs. 2. networkd-config.sh does not register an initqueue/finished hook when rd.neednet=1 is set, so dracut-initqueue exits immediately when the root device is local without running networkd-run.sh. 3. networkd-run.sh does not populate /etc/resolv.conf from DHCP or kernel command-line DNS servers, leaving chronyd unable to resolve pool.ntp.org. Install libnss_dns.so.* in 11systemd-networkd, register the initqueue/finished/networkd.sh hook when rd.neednet=1, and populate /etc/resolv.conf from kernel command-line nameserver= arguments and /run/systemd/netif/state DNS options in networkd-run.sh. Fixes: https://github.com/dracut-ng/dracut/issues/2541 --- modules.d/11systemd-networkd/module-setup.sh | 2 ++ modules.d/11systemd-networkd/networkd-config.sh | 2 ++ modules.d/11systemd-networkd/networkd-run.sh | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/modules.d/11systemd-networkd/module-setup.sh b/modules.d/11systemd-networkd/module-setup.sh index 484ccd3..9f38a06 100755 --- a/modules.d/11systemd-networkd/module-setup.sh +++ b/modules.d/11systemd-networkd/module-setup.sh @@ -72,6 +72,8 @@ install() { inst_hook cmdline 99 "$moddir"/networkd-config.sh inst_hook initqueue/settled 99 "$moddir"/networkd-run.sh + inst_libdir_file {"tls/$DRACUT_ARCH/",tls/,"$DRACUT_ARCH/",}"libnss_dns.so.*" + # Enable systemd type units for i in \ systemd-networkd.service \ 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

