DæmonNews: News and views for the BSD community

Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

Rebuilding the OpenBSD kernel

by Brad Schonhorst

The kernel is the core of the operating system. It is the binary file that the computer loads first and stores in memory. Because it is stored in memory, the kernel needs to be as small as possible. The kernel usually lives in the root directory ('/') and by default is called 'bsd'.

Users who want their OpenBSD machine to perform specific functions or need additional device drivers might want to customize their kernel. In other OS's, like some types of Linux, it is very popular to rebuild the kernel because the default is so bloated. For most users, the default OpenBSD kernel is sufficient; however, you should still apply kernel patches, which will require rebuilding and installing a fresh kernel.

You will need the system source code and patches. I will assume both of these have been installed. If not, check out my Patching OpenBSD instructions. You can apply many patches to the kernel source before rebuilding, but make sure you apply them in order!

Building a new kernel

1. Using the appropriate working directory

First you'll need to get into the appropriate working directory. This depends on the platform you are using. This example is for a macppc, but you should use your platform's directory instead (e.g., i386, alpha, etc...).

$ cd /usr/src/sys/arch/macppc/conf

2. Configuring

Now we can configure it with the generic macppc configuration file.

$ sudo /usr/sbin/config GENERIC

3. Building

Next we will build the new kernel using make(1). The make program simplifies the maintenance and compiling of other programs. We will first change to the correct directory and then run the make program. The second step will take a while.

$ cd /usr/src/sys/arch/macppc/compile/GENERIC
$ sudo make clean && sudo make depend && sudo make

Installing the new kernel

We have now created a new kernel, but it is not in the right place yet. If you reboot your computer, it will launch the existing kernel in '/'. The one we just built is still in /usr/src/sys/arch/macppc/compile/GENERIC/. We need to move it so that it loads when we reboot.

4. Making a backup

We make a backup copy of our old kernel in case the new one won't boot.

$ sudo cp /bsd /bsd.old

5. Putting the kernel in place

Now we can copy our new kernel to '/' and try it out. It is a good idea to make sure the permissions are set correctly, too.

$ sudo cp /usr/src/sys/arch/macppc/compile/GENERIC/bsd /bsd
$ sudo chown root:wheel /bsd

All done

Now that the kernel is built and installed, you can reboot and load it!

$ sudo reboot

For clarification or corrections, contact bschonhorst@gmail.com.

Google
Web daemonnews.org

More Articles
  • Stupid Launchd Tricks
  • Installing BSD on IBM Netvista S40 - Part 5: OS/2 Installation
  • Review: Nagios System and Network Monitoring
  • Working with gmirror and a Sun Fire X2100 (part 2)
  • Working with gmirror and a Sun Fire X2100 (part 1)
  • Open Source Initiatives and You...
  • Installing BSD on IBM Netvista S40 - Part 4: NetBSD Installation
  • Book Review: Open Source Pen Testers Toolkit
  • Daemon's Advocate
  • BSDCan 2006 Friday Photos
  • Installing BSD on IBM Netvista S40 - Part 3: DragonFly Installation
  • BSDCan 2006 Photos
  • AFS: network filesystem beyond NFS weaknesses
  • Mastering FreeBSD and OpenBSD Security
  • Installing BSD on IBM Netvista S40 - Part 2: FreeBSD Installation

  • Advertisements

    BSD News
  • SCALE 5x - Open Source Confernece In Los Angeles This Weekend
  • Open source is the ticket for In Ticketing
  • FreeBSD 4.x EoL
  • Submit A News Item
  • Stupid Launchd Tricks
  • Win a trip to BSDCan 2007
  • DragonFly BSD 1.8 Released
  • Why Gentoo Shouldn 't be on Your Server
  • Java/PAE Woes in FreeBSD



  • Author maintains all copyrights on this article.
    Images and layout Copyright © 1998-2006 Dæmon News. All Rights Reserved.