NOTE: This is not even close to being done.
I will work on this Sunday, Aug 27 2k and get it finished.


OBJECTIVE: To compile a very small, efficient kernel. Depending on your environment, you may leave more things in your kernel than I do. My machines rarely change configuration once they are setup (I dont cram in new network cards, and if I add a hard drive, its usually the same brand and model as the existing ones), so I have a tendency to remove a huge amount from the kernel before compiling it. Leaving in extra stuff in your kernel wont hurt it, but my goal is to remove as much as possible for the most efficiency. YMMV, so use your own discretion.
APPLIES TO: OpenBSD v2.6 - 2.7 (some options discussed will only be available with the newest version, which is 2.7. I suggest you upgrade to version 2.7 if you're running an older version - there are a lot of new, cool features in the latest release, and some of the things I mention to remove or add may not be in an older version. Keep in mind, these instructions are for not for Alpha or Sparc based systems, only Intel based systems. (or AMD or .. I suppose even Cyrix. You get the idea.)
ADDITIONAL NOTES: I do have a Sparc 20 here, so I guess I could write one up about the Sparc architecture, but for now these instructions are strictly for PC's.
WHAT YOU WILL NEED:
    An Intel/AMD based system running OpenBSD, v2.7 preferred.
    A copy of the output from your 'dmesg' command. (1)
    Kernel Sources. (2)
    Three brain cells (3)

    After you have your kernel sources installed, (they dont come with a stock install), change to the directory where the sources are stored:


# cd /usr/src/sys/arch/i386/conf

    Now you're going to make a quick upgrade folder:


# mkdir /kernel-up

    K, now you're going to copy your GENERIC kernel setup over to your temporary space, (/kernel-up), and name it something. We'll name ours 'OPENFIRE' for this example.


# cp GENERIC /kernel-up/OPENFIRE

# vi OPENFIRE
(edit OPENFIRE to your liking) # cd ../compile/MYKERNEL
# make clean && make depend && make
# cp /bsd /bsd.old && cp bsd /bsd
# chown root.wheel /bsd (if you compiled as someone else)
(reboot)



(1) Unless you have super-human memory, a copy of your dmesg output will really help you slice your kernel size down. I usually ssh into the box and copy/paste the dmesg output to notepad, so I can check to see what parts of the kernel are needed/used, based on the dmesg output. You can do whatever feels comfortable to you.

(2) OpenBSD doesn't install kernel sources by default. This is probably because of Theo's rampant paranoia (which is great.) Presumably, it will make the job of a cracker slightly harder if there is no kernel source installed on your system -- he wont be able to compile backdoors, customizations, etc into your kernel if you dont have the sources there to do it. Go here for instructions on getting your sources downloaded and installed.

(3) You could probably make do with just two.. not sure. I've only tried it with three.