Building the NetBSD kernel

grab-binary | grab-source | kernel | cross | world | tweak

assuming same NetBSD release or at least branch – no need to build tools

make sure you have enough RAM (at least 2GB I would say, but 8GB is probably preferable), and eventually increase the number of vcpus

Easy-peasy kernel-only

you don’t have to download all the sources, but that works only on same release

kernel=PFALTQ
kernel=DOMU-PFALTQ

cd /usr/src/sys/arch/amd64/conf/
diff -Naur GENERIC $kernel > $kernel.diff
diff -Naur XEN3_DOMU $kernel > $kernel.diff

config $kernel
#/usr/tooldir/bin/nbconfig GENERIC_XENHVM

dmesg | grep -E [v]?cpu

cd ../compile/$kernel/
time make -j3 depend > $kernel.depend.log && echo READY
#/usr/tooldir/bin/nbmake

#make clean
time make -j3 > $kernel.log && echo BUILT
#/usr/tooldir/bin/nbmake

Ready to go

deploy on bare-metal

mv /netbsd /netbsd.old
cp /usr/src/sys/arch/`uname -m`/compile/$kernel/netbsd /
shutdown -r now

–or– on a XEN host

scp domU:/usr/src/sys/arch/amd64/compile/PFALTQ/netbsd pfaltq
scp domU:/usr/src/sys/arch/amd64/compile/DOMU-PFALTQ/netbsd domu-pfaltq

scp pfaltq dom0:/data/kernels/netbsd93/
scp domu-pfaltq dom0:/data/kernels/netbsd93/

apply the change to the XEN guest – change its settings to point to the new kernel

shutdown -p now
kernel = "/data/kernels/netbsd93/domu-pfaltq"

at system startup, watch the console and check

dmesg | grep ^NetBSD
uname -a

Shooting troubles

make[1]: don't know how to make absvdi2.c. Stop

==> either use config -s or put your sources folder in the default location (/usr/src)

while trying to run PFALTQ (based on GENERIC) as PVH guest

xc: error: panic: xg_dom_hvmloader.c:110: xc_dom_parse_hvm_kernel: ELF image is not 32bit: Invalid kernel

==> PVH support is in current, not 9.3 just yet

Resources

https://www.netbsd.org/docs/kernel/

https://www.netbsd.org/docs/guide/en/chap-kernel.html

https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/BUILDING

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/mk/bsd.README


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun