Re: [PATCH] kbuild: depmod: fallback to /boot/System.map-KERNELRELEASE

From: Nicolas Schier

Date: Fri Oct 16 2026 - 10:23:32 EST


On Fri, Oct 16, 2026 at 01:11:06PM +0200, Adrián García Casado wrote:
> When installing external modules (M=...) against packaged kernel headers
> such as linux-headers built via 'make bindeb-pkg', ${objtree}/System.map
> is absent because System.map is located in:
> /boot/System.map-${KERNELRELEASE}
>
> Currently, scripts/depmod.sh only checks ${objtree}/System.map and skips
> running depmod with a warning, leaving newly installed out-of-tree
> modules unindexed in modules.dep.
>
> Fall back to ${INSTALL_MOD_PATH}/boot/System.map-${KERNELRELEASE} when
> ${objtree}/System.map is not readable so that depmod runs properly
> during external module installation.
>
> Signed-off-by: Adrián García Casado <adriangarciacasado42@xxxxxxxxx>
> ---
> scripts/depmod.sh | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/depmod.sh b/scripts/depmod.sh
> index 3c34fecac..d6d1b9547 100755
> --- a/scripts/depmod.sh
> +++ b/scripts/depmod.sh
> @@ -12,9 +12,14 @@ KERNELRELEASE=$1
>
> : ${DEPMOD:=depmod}
>
> -if ! test -r "${objtree}/System.map" ; then
> - echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
> - exit 0
> +system_map="${objtree}/System.map"
> +if ! test -r "${system_map}" ; then
> + if test -r "${INSTALL_MOD_PATH}/boot/System.map-${KERNELRELEASE}" ; then
> + system_map="${INSTALL_MOD_PATH}/boot/System.map-${KERNELRELEASE}"
> + else
> + echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
> + exit 0
> + fi
> fi
>
> # legacy behavior: "depmod" in /sbin, no /sbin in PATH
> @@ -25,7 +30,7 @@ if [ -z $(command -v $DEPMOD) ]; then
> exit 0
> fi
>
> -set -- -ae -F "${objtree}/System.map"
> +set -- -ae -F "${system_map}"
> if test -n "$INSTALL_MOD_PATH"; then
> set -- "$@" -b "$INSTALL_MOD_PATH"
> fi
> --
> 2.39.5
>

Thanks for report and patch.

For the record, this is what I can find in Debian's Linux packages:

Debian puts a dummy System.map to /lib/modules/$(KERNELVER)/System.map
(linux-image-$(KVER)-$(DEBVER)-$(ARCH).deb) and the real System.map is
only available in linux-image-$(KVER)-$(DEBVER)-$(ARCH)-dbg package
at /usr/lib/debug/lib/modules/$(KVER)-$(ARCH)/System.map.

So, do we need a valid System.map for out-of-tree modules?

At a first glance, you patch looks good to me. But lets way some days
for other feedback.

Kind regards,
Nicolas