Having multiple (pkgbase) kernels vs. /etc/rc* related activities at boot: does not respect kernel= or kern.module_path= from loader.conf

From: Mark Millard <marklmi_at_yahoo.com>
Date: Tue, 20 Feb 2024 21:48:05 UTC
My example for this generel subject is going to be nfsd :

# uname -apKU
FreeBSD armv7-main-pkgs 15.0-CURRENT FreeBSD 15.0-CURRENT main-n267775-6ec8bf9f3d17 GENERIC-NODEBUG arm armv7 1500012 1500012

(It has been a while since armv7 pkgbase published anything new.
This still has /boot/dtb/ files bound with the kernel.)

# grep '^kern.*="kernel' /boot/loader.conf
kernel="kernel.GENERIC-NODEBUG"
kern.module_path="kernel.GENERIC-NODEBUG"

But the boot got:

Starting ntpd.
kldload: can't load nfsd: No such file or directory
/etc/rc: WARNING: Unable to load kernel module nfsd
/etc/rc: WARNING: failed precmd routine for nfsd

Why? load_kld in /etc/rc.subr does:

. . .
        if ! $_loaded; then
                if ! kldload "$1"; then
                        warn "Unable to load kernel module $1"
                        return 1
                else
. . .

but that kldload looks in /boot/kernel/ despite the
kernel= and kern.module_path= use in loader.conf .

As stands this context has /boot/kernel.GENERIC-NODEBUG/
but does not have /boot/kernel/ . (In part this is because
armv7 pkgbase still predates /boot/dtb/ being separate
from the kernels.)

But even if /boot/kernel/ had been populated as well, use
of its contents with /boot/kernel.GENERIC-NODEBUG/kernel
having been loaded and booted is likely to (at times?) be
an inappropriate mix of /boot/kernel.GENERIC-NODEBUG/ and
/boot/kernel/ materials.

===
Mark Millard
marklmi at yahoo.com