From b4949703f2f4741081accf74072f7610789d4e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 11 Jun 2026 14:44:22 +0200 Subject: [PATCH] fixup! build: split NVIDIA rootfs into base-nvidia image + gpu addon --- .../rootfs-builder/nvidia/nvidia_rootfs.sh | 34 ++++++++++++++++++- .../static-build/busybox/busybox.nvidia.conf | 16 +++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tools/osbuilder/rootfs-builder/nvidia/nvidia_rootfs.sh b/tools/osbuilder/rootfs-builder/nvidia/nvidia_rootfs.sh index d50f4de74a..b1c3e20872 100644 --- a/tools/osbuilder/rootfs-builder/nvidia/nvidia_rootfs.sh +++ b/tools/osbuilder/rootfs-builder/nvidia/nvidia_rootfs.sh @@ -553,6 +553,38 @@ chisseled_veritysetup() { cp -a "${stage_one}/${libdir}"/libcap.so.2* "${libdir}/." } +# NVRC loads each addon's NVIDIA kernel modules from that addon's self-contained +# module tree via `modprobe --dirname ` (a kmod feature). The base ships +# busybox, whose modprobe is built without long options and has no --dirname, so +# the base must carry the real kmod. This keeps modules composable: every +# module-bearing addon stays independent (its own modules.dep from depmod -b) and +# nothing has to shadow the read-only /lib/modules. kmod is a single multi-call +# binary that embeds libkmod (no libkmod2 to ship); modprobe/insmod/... are +# argv[0] symlinks to it. Runs inside ${ROOTFS_DIR}. +chisseled_kmod() { + echo "nvidia: chisseling kmod" + + local libdir="lib/${machine_arch}-linux-gnu" + + cp -a "${stage_one}/usr/bin/kmod" usr/bin/. + + # kmod picks its applet from argv[0]. Expose the module tools as symlinks; + # /sbin/modprobe (NVRC's absolute path) shadows the busybox modprobe applet. + # Absolute targets so they resolve regardless of whether /sbin is a real dir + # or a usr-merge symlink. + local tool + for tool in modprobe insmod rmmod depmod lsmod; do + ln -sf /usr/bin/kmod "sbin/${tool}" + done + + # kmod links libzstd/liblzma unconditionally (compressed-module support); + # our modules are uncompressed but the NEEDED entries must still resolve. + # libcrypto/libc are already present (libc from chisseled_compute, libcrypto + # from chisseled_veritysetup). + cp -a "${stage_one}/${libdir}"/libzstd.so.1* "${libdir}/." + cp -a "${stage_one}/${libdir}"/liblzma.so.5* "${libdir}/." +} + setup_nvidia_gpu_rootfs_stage_two() { readonly stage_two="${ROOTFS_DIR:?}" readonly stack="${NVIDIA_GPU_STACK:?}" @@ -617,7 +649,7 @@ setup_nvidia_gpu_rootfs_stage_two() { # Carve the freshly chiseled (monolith) tree into the requested layout. # The monolith path is left untouched. case "${layout}" in - base) partition_base; chisseled_veritysetup ;; + base) partition_base; chisseled_veritysetup; chisseled_kmod ;; gpu-addon) partition_gpu_addon ;; esac fi diff --git a/tools/packaging/static-build/busybox/busybox.nvidia.conf b/tools/packaging/static-build/busybox/busybox.nvidia.conf index 21b2e7ffeb..66cac10af7 100644 --- a/tools/packaging/static-build/busybox/busybox.nvidia.conf +++ b/tools/packaging/static-build/busybox/busybox.nvidia.conf @@ -564,14 +564,18 @@ CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="" # CONFIG_LSMOD is not set # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set # CONFIG_MODINFO is not set -CONFIG_MODPROBE=y -CONFIG_FEATURE_MODPROBE_BLACKLIST=y +# CONFIG_MODPROBE is not set +# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set # CONFIG_RMMOD is not set # # Options common to multiple modutils # -CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y +# The base-nvidia image ships the real kmod (modprobe/insmod/...) so that NVRC +# can load each addon's modules with `modprobe --dirname `; busybox's +# modprobe lacks long options (no --dirname), so all busybox modutils are +# disabled here to avoid a dead, conflicting applet shadowing kmod. +# CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS is not set # CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set # CONFIG_FEATURE_2_4_MODULES is not set # CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set @@ -581,10 +585,8 @@ CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set # CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set # CONFIG_FEATURE_INSMOD_TRY_MMAP is not set -CONFIG_FEATURE_MODUTILS_ALIAS=y -CONFIG_FEATURE_MODUTILS_SYMBOLS=y -CONFIG_DEFAULT_MODULES_DIR="/lib/modules" -CONFIG_DEFAULT_DEPMOD_FILE="modules.dep" +# CONFIG_FEATURE_MODUTILS_ALIAS is not set +# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set # # Linux System Utilities