Since April 28, 2025, NetBSD's build system (on amd64 for now) has a new option "KERNEL_DIR". It allows having a kernel and the corresponding debug kernel and kernel modules all together in a directory.

The option can be used from build.sh like this:

build.sh -VKERNEL_DIR=yes ...

and build a new kernel and distribution.

Then make sure your third-stage bootloader is up-to-date. For example, if you're booting via GPT from an EFI partition, install an up-to-date /usr/mdec/bootx64.efi into /efi/boot on the EFI partition.

The new structure then is as follows:

Instead of

/netbsd # kernel
/netbsd.gdb # kernel with debugging symbols
/stand/amd64/10.99.12/modules # kernel modules

you'll have these files:

/netbsd/kernel # kernel
/netbsd/kernel.gdb # kernel with debugging symbols
/netbsd/modules # kernel modules

The bootloader will try loading /netbsd/kernel, /onetbsd/kernel, /netbsd.old/kernel in that order.

Please note, the boot loader UI changes slightly. If you want to load a custom kernel, you must specify directory and path, i.e.

boot /netbsd.test/kernel

(A change request to simplify this has been filed.)

A possible update process would look like this:

rm -rf /onetbsd
mv /netbsd /onetbsd
mkdir /netbsd
copy new kernel{,.gdb} into /netbsd
build.sh install=/ -V KERNEL_DIR ... # for the rest, including new modules