Building the FreeBSD kernel

tested on FreeBSD 12.1/ZFS then 13.0/EXT2FS

Introduction

We are here adding kernel features to the GENERIC vs. MINIMAL templates. FreeBSD XEN/PVH doesn’t have a loader hence doesn’t know how to load modules, be it zfs.ko or ext2fs.ko.

Requirements

ls -lF /usr/src/ # nothing yet

pkg install wget

cd /root/
wget https://download.freebsd.org/snapshots/amd64/13.2-STABLE/src.txz
tar xf src.txz -C /
rm -f src.txz

Build

it make it easy for xen guest mgmt to avoid modules

echo NO_MODULES=1 >> /etc/make.conf

cd /usr/src/sys/amd64/conf/

ext2fs

cp -pi MINIMAL MINIMAL-EXT2FS
vi MINIMAL-EXT2FS

options     EXT2FS

zfs

cp -pi MINIMAL MINIMAL-ZFS
vi MINIMAL-ZFS

options     ZFS

built-in PF

device          pf
device          pflog
device          pfsync

options         ALTQ
options         ALTQ_CBQ        # Class-Based Queuing (CBQ)
options         ALTQ_RED        # Random Early Detection (RED)
options         ALTQ_RIO        # RED In/Out
options         ALTQ_HFSC       # Hierarchical Packet Scheduler (HFSC)
options         ALTQ_PRIQ       # Priority Queueing (PRIQ)

moar

options         BPF_JITTER

shared

config MINIMAL-EXT2FS
cd ../compile/MINIMAL-EXT2FS/

config MINIMAL-ZFS
cd ../compile/MINIMAL-ZFS/

make cleandepend && make depend
time nice make > /root/kernel-build.log && echo BUILT || echo FAIL
tail /root/kernel-build.log

Acceptance

ls -lhF /usr/src/sys/amd64/compile/MINIMAL-EXT2FS/kernel
strings /usr/src/sys/amd64/compile/MINIMAL-EXT2FS/kernel | grep -i ext2fs
strings /usr/src/sys/amd64/compile/MINIMAL-EXT2FS/kernel | grep -i pfsync

ls -lhF /usr/src/sys/amd64/compile/MINIMAL-ZFS/kernel
strings /usr/src/sys/amd64/compile/MINIMAL-ZFS/kernel | grep -i zfs

Ready to go

grab the built kernel and push it to some dom0 host

from workstation

scp freebsd:/usr/src/sys/amd64/compile/MINIMAL-EXT2FS/kernel minimal-ext2fs
scp minimal-ext2fs XEN-HOST:/data/kernels/freebsd132/

Resources

make.conf – system build information https://www.freebsd.org/cgi/man.cgi?make.conf(5)

8.3 Building and Installing a Custom Kernel https://docs.freebsd.org/doc/6.1-RELEASE/usr/share/doc/handbook/kernelconfig-building.html

8.5. Building and Installing a Custom Kernel https://www.freebsd.org/doc/handbook/kernelconfig-building.html

Chapter 26. Updating and Upgrading FreeBSD https://docs.freebsd.org/en/books/handbook/cutting-edge/

https://forums.freebsd.org/threads/build-pf-into-a-10-2-kernel.53109/ ==> device pf

https://www.experts-exchange.com/articles/17343/Compiling-a-custom-FreeBSD-kernel-with-Packet-Filtering-PF-and-Alternate-Queuing-ALTQ.html ==> options altq


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