pxe: Blancco initrd pulls in module deps and NIC firmware

The kexec-initrd build copied a fixed set of module directories plus
drivers/net/mii.ko. Ubuntu ships that as mii.ko.zst, so the -e test
skipped it, and usbnet, r8152 and cdc_ether then failed to load with
"Unknown symbol mii_*": USB-C to RJ45 adapters never appeared (seen
2026-10-05, Dell USB-C adapter). igb lacked dca and i2c-algo-bit the
same way.

Walk the host modules.dep from the copied modules and copy every
dependency (73 on 6.8.0-71). Also copy rtl_nic, tigon, bnx2, bnx2x and
e100 firmware, which those drivers request at probe.
This commit is contained in:
cproudlock
2026-10-05 11:56:16 -04:00
parent 25f65424c7
commit 372c3802e5

View File

@@ -862,13 +862,47 @@
cp -r "$NETDIR/$sub/"* "$WORK/lib/modules/$KVER/kernel/drivers/net/$sub/" 2>/dev/null || true cp -r "$NETDIR/$sub/"* "$WORK/lib/modules/$KVER/kernel/drivers/net/$sub/" 2>/dev/null || true
fi fi
done done
# Overlay + squashfs + loop + usb + hid + ptp + mii + net/core deps # Overlay + squashfs + loop + usb + hid + ptp + net/core
for modpath in fs/overlayfs fs/squashfs drivers/block drivers/usb/core drivers/usb/host drivers/hid drivers/ptp drivers/net/mii.ko net/core; do for modpath in fs/overlayfs fs/squashfs drivers/block drivers/usb/core drivers/usb/host drivers/hid drivers/ptp net/core; do
if [ -e "/lib/modules/$KVER/kernel/$modpath" ]; then if [ -e "/lib/modules/$KVER/kernel/$modpath" ]; then
mkdir -p "$WORK/lib/modules/$KVER/kernel/$(dirname $modpath)" mkdir -p "$WORK/lib/modules/$KVER/kernel/$(dirname $modpath)"
cp -r "/lib/modules/$KVER/kernel/$modpath" "$WORK/lib/modules/$KVER/kernel/$modpath" 2>/dev/null || true cp -r "/lib/modules/$KVER/kernel/$modpath" "$WORK/lib/modules/$KVER/kernel/$modpath" 2>/dev/null || true
fi fi
done done
# Pull in every module the copied ones depend on, from the host's
# modules.dep. A fixed list misses them: drivers/net/mii.ko was named
# here but ships as mii.ko.zst, so the test skipped it and usbnet,
# r8152 (USB-C to RJ45 adapters) and cdc_ether failed with "Unknown
# symbol mii_*"; igb likewise lacked dca and i2c-algo-bit.
python3 - "$KVER" "$WORK" <<'PYDEP'
import os, shutil, sys
kver, work = sys.argv[1], sys.argv[2]
src = f"/lib/modules/{kver}"
dst = f"{work}/lib/modules/{kver}"
dep = {}
for line in open(f"{src}/modules.dep"):
k, v = line.split(":", 1)
dep[k] = v.split()
have = {os.path.relpath(os.path.join(r, f), dst)
for r, _, fs in os.walk(dst) for f in fs if ".ko" in f}
todo, added = list(have), 0
while todo:
for d in dep.get(todo.pop(), []):
if d not in have:
have.add(d); todo.append(d); added += 1
os.makedirs(os.path.dirname(f"{dst}/{d}"), exist_ok=True)
shutil.copy2(f"{src}/{d}", f"{dst}/{d}")
print(f"added {added} dependency modules")
PYDEP
# NIC firmware the drivers request at probe (r8152/r8169 rtl_nic
# patches, tg3, bnx2/bnx2x, e100). The kernel loads .zst firmware.
for fw in rtl_nic tigon bnx2 bnx2x e100; do
if [ -d "/lib/firmware/$fw" ]; then
mkdir -p "$WORK/lib/firmware"
cp -r "/lib/firmware/$fw" "$WORK/lib/firmware/"
fi
done
# Decompress zstd modules in-place (busybox insmod can't handle .zst) # Decompress zstd modules in-place (busybox insmod can't handle .zst)
find "$WORK/lib/modules" -name '*.ko.zst' -print0 | \ find "$WORK/lib/modules" -name '*.ko.zst' -print0 | \