OpenBSD Compile Custom Kernel

Page content

Let’s Compile a Custom Kernel for OpenBSD … and let’s check if we can tune the Process it with multiple Processors.

get Sources and prepare Custom Kernel

cd /usr/src
ftp$(uname -r)/sys.tar.gz
tar xfz sys.tar.gz
rm xfz sys.tar.gz
cd /sys/arch/$(uname -m)/conf
config CUSTOM.MP
cd ../compile/CUSTOM.MP

-> with config CUSTOM.MP, you can enable disable Components which will be built into your Custom Kernel. Wlan Drives for a VirtualServer, as example, does not make sense.


start the build process without arguments. One Kernel is used …

make clean
time make

… as we can see in the “htop”. 1 CPU in used, the Load of the Systems is also 1.

Time to Go: 38min … (38m00.28s real 29m30.71s user 8m44.51s system)

Let’s try with 4 Cores

Most (Virtual) Machines got multiple CPU’s, respectively Cores. Let’s try to Speedup the Build Process with enabling Multiple Cores. The “-j” Flag is sused to tell to the Compile how many Core it should use.

make clean
time make -j 4
make install
uname -a

Time to Go: 9.30min (9m35.44s real 27m52.17s user 9m03.97s system)

and finally with 16 Cores

Compile the Kernel with all possible Cores. In our Example, we have 16 Cores and we wanne use them!

make clean
time make -j $(sysctl hw.ncpufound |cut -d= -f 2)
make install
uname -a

Time to Go: 4:30 (4m26.83s real 39m18.96s user 18m59.31s system)

Install and Reboot

and finally, install the Kernel, reboot and check the loaded Kernel after reboot

make install
uname -a
# -> OpenBSD pbuilder-demo 7.1 GENERIC.MP#3 amd64

uname -a
# -> OpenBSD pbuilder-demo 7.1 CUSTOM.MP#1 amd64

Compare with Vultr PowerBox

  • 8 vCPU / AMD EPYC-Rome Processor
  • 16 GB RAM
  • 350 GB Disk
  • -> 96 USD/Month

Time with

  • 1 CPU: 14m09.98s
  • 8 CPU: 4m03.12s

Happy Compiling !

sha256: 3ad6ce823e998b70dff32be250231d5bf24aded5837d1584cf2855849274685b