Druid628 :: Tech Tips :: BSD Kernel

[Print-friendly]


 

Recompiling the FreeBSD Kernel

Preparation

When it comes time to compile the FreeBSD kernel which is always such a fun thing to do, but MAKE SURE you make a boot disk. You need to have the sys sources installed, you should be able to type:

# cd /sys


if you don't have these you can do by running (as root)

# /stand/sysinstall

and choosing "configure" next select "distribution", then "src" and finally "sys", this will install the source files needed into the /
usr/src/sys directory.

To begin your Kernel adventure change your working directory to
/usr/src/sys/i386/conf
there you willl have the two files you need GENERIC and LINT

GENERIC configuration file the kernel boots from
LINT advanced configuration file for more hardware and device driver support
   

Configure your kernel

First things first, copy the GENERIC file into a file named after your favorite cartoon character  like so:

# cp GENERIC CARTMAN

DO NOT DELETE "GENERIC" OR "LINT" if you do Beastie will come stick you with his pitch fork, and I mean that!

Edit your new kernel file (in this case CARTMAN)  using your favorite Text Editor. (vi is your friend)  Make the changes necessary by commenting out or removing the stuff you don't need, such as SCSI, RAID, etc etc.. ( Know your system before you start jerking out lines you think you don't need)

I bet by now you are wondering why you need that LINT file, right?
FreeBSD doesn't detect sound cards own its own, you have to put it in there! To add sound you need to go look at your LINT file.  I am running FreeBSD 4.3 and the snd0 device driver is no longer standard use now it's all pretty much
device pcm

Next run config <filename>

#config CARTMAN

If you encounter any errors then you goofed up in the file go fix it!
 

Compiling your kernel

Next you will need to change your working directory to /usr/src/sys/compile/<filename>

#cd /usr/src/sys/compile/CARTMAN

To compile you need only three more steps and Ta-Da your done!

#make depend
#make
#make install

This is a rather long process so make sure you have lots of caffeine. To explain what you've just done with these three commands   make depend runs a series of Perl scripts that gather source code. Make actually compiles the kernel with all the new stuff you've done to it. Make install actually installs it into your root directory "/" it also renames your current kernel.GENERIC to kernel.old and puts the new kernel in it's place.
Now reboot and ta-da you win!

 

Just the commands

# cd /usr/src/sys/i386/conf
# cp GENERIC CARTMAN
# vi CARTMAN
# config CARTMAN
# cd /usr/src/sys/compile/CARTMAN
# make depend
# make
# make install
# reboot