Building the NetBSD kernel

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

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

first see netbsd-tweaks then proceed with building

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

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

dmesg | grep -E [v]?cpu
echo $MAKEFLAGS

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

Ready to go

–either– deploy locally (bare-metal or KVM guest)

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

–or– keep a remote copy of it (e.g. for a XEN host)

guest=netbsd-lbs
conf=PFCOM1
kernel=netbsd100.pfcom1

ssh -tn $guest ls -lhF /usr/src/sys/arch/amd64/compile/$conf/netbsd
scp $guest:/usr/src/sys/arch/amd64/compile/$conf/netbsd $kernel
chmod -x $kernel

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

shutdown -p now
kernel = "/data/kernels/netbsd100.pf"

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