Building a custom kernel
Configuring the kernel
Copy these two files to a directory where you have write access as a normal user:
cp /usr/src/sys/arch/i386/conf/GENERIC /home/alex/MYCENE/MYCENE
cp /usr/src/sys/conf/GENERIC /home/alex/MYCENE/MYCENE-common
Edit the line in the new file called MYCENE that reads:
include "../../../conf/GENERIC"
and replace it by:
include "/home/alex/MYCENE/MYCENE-common"
The directory /home/alex is my home directory, the directory /home/alex/MYCENE is the name of the machine for which we’ll build a new kernel. In that directory we just copied the kernel configuration files MYCENE and MYCENE-common. The file MYCENE lists the machine dependend kernel configuration options. In MYCENE-common are some platform independend options. Edit those two files to your own liking and the machine’s needs.
More info on this follows soon..
Compiling the kernel
Now, in the directory /home/alex/MYCENE/, we create a directory called build for the necessary files to build a working kernel and then we issue the following configuration command to create all the necessary files in the previously created build/ directory:
config -s /sys -b build MYCENE
After that, we change directory to build/ and create the .depend files necessary for the success of compilation process:
make depend
Only then, we can start to compile our neat little kernel and eat some pizza:
make
Installing the kernel
Now, if we’re lucky, make has made us a shiny new kernel, located in build/ as bsd.
su to root, save /bsd to /bsd-dist if the current /bsd kernel image is the one installed by the installation process. Else save it as /bsd-old. This way we’ll be able to boot a working kernel if our new one is broken in some way.
Finally, we can safely copy ~alex/MYCENE/build/bsd over the old /bsd kernel image and issue a reboot to test it.
# su
# cd /
# cp bsd bsd-dist
# cp ~alex/MYCENE/build/bsd .
# reboot
[...] See Configuring the kernel for this. [...]