BSD DevCenter
oreilly.comSafari Books Online.Conferences.


OpenBSD Explained

OpenBSD Kernel Compilation and Optimization


As a completely open source system, OpenBSD benefits from the innate ability to be totally recompiled from scratch. This, of course, also includes the ability to rebuild the kernel, which is the "heart" of any operating system. Recompiling a kernel with specific options and parameters will provide not only driver support, but also powerful optimization and speed enhancements for your entire system.

To recompile, you need a full syssrc tree, which can be downloaded via either CVS or FTP. CVS will provide you with a bleeding-edge -CURRENT source tree, while a "release" kernel source tree can be downloaded via FTP.

To download via CVS:

export CVS_RSH="/usr/bin/ssh"

This sets CVS to run over SSH, which provides encryption and compression.


This sets the CVS server from which to download the tree. You can also view a full list of servers and syntax options.

cd /usr && cvs checkout -z9 src/sys

This downloads, with -z9 (high grade) compression, the entire kernel source tree for all architectures.

To download via FTP, simply point a browser or ftp client at:

Then put this into /usr/src and extract:

cp srcsys.tar.gz /usr/src ; tar -xzf /usr/src/srcsys.tar.gz

From this point, the process of kernel configuration and compilation is roughly a three step process.

Step 1

OpenBSD kernels, as opposed to Linux's kernel configuration utilities, draw their options entirely from a single configuration file, which resides in /usr/src/sys/arch/$ARCH/conf/ ($ARCH being your system architecture - each architecture has some options specific to it). Several example files are included for each architecture, but I find GENERIC the best for a first-time user to hack up. A lot of options are required for that particular architecture and should not be changed, and a lot are quite complex and extremely unlikely to be changed, so it's highly suggested to tinker, yet not expect a kernel to work properly if unknown options are changed. I'll run through a series of recommended tweaks to improve specific performance, some of which are i386 specific:

Processor & I/O:

option          I686_CPU

Select only one CPU option (this, if you have an i686) and hash out the rest. (Hash out means to comment out by putting a # at the front of the line.)

#option         GPL_MATH_EMULATE
Hash this option out unless you have a very old machine with no FPU.

option         DUMMY_NOPS
General speed hack.

option          UVM
Advanced Virtual Memory system. Speeds up a machine when swapping.

option          MFS
Memory File System. Can be used to create RAMDISK partitions for extremely fast data access.


option NMBCLUSTERS="8192"
Speeds up network operations under heavy traffic and prevents kernel panics under these conditions. A value of 1024 or 2048 is more suitable for systems with less traffic.

ef*     at isapnp?         # 3C515 PnP ethernet
This line and all those surrounding it in the GENERIC config file denote Ethernet chipset drivers. Hash out ALL unused drivers to speed up boot and free up memory.

Disk/Block Device:

ahc*    at pci? dev ? function ?    # Adaptec 2940 SCSI controllers
This line and all those surrounding it in the GENERIC config file denote SCSI and other block device drivers. Hash out ALL unused drivers to speed up boot and free up memory.

Reserves 45% of system memory as a filesystem buffer. A lower value is recommended, depending on how much free memory your system has. This is a good way to squeeze extra performance from large areas of idle memory.

Pages: 1, 2

Next Pagearrow

Sponsored by: