Exercise 3: rebuilding the FreeBSD kernel ========================================= This is an example of a very large C program! You must be *root* for this exercise. Configure the kernel -------------------- The kernel configuration file sets various options about how the kernel is built. The easiest way to create this is to copy the GENERIC kernel configuration and modify it. # cd /usr/src/sys/i386/conf # cp GENERIC AFNOG2005 # vi AFNOG2005 Things you should change: * Change the "ident" line to the name of your new kernel * For maximum efficiency, you can remove the "cpu" lines for processor types which you don't need. You can do this by deleting the lines, or by prefixing them with a hash (which turns them into comments) machine i386 #cpu I486_CPU #cpu I586_CPU cpu I686_CPU ident AFNOG2005 * You can remove the line "options INET6" to remove IPv6 support from the kernel * You can safely remove "device eisa" (but don't remove "isa" or "pci") For now, that's all we'll change. In real life you could remove all the SCSI controllers (but leave scbus and da, as they're needed for USB memory cards); you could remove all the network card drivers you don't need; and so on. Once this is done, and still in the /usr/src/sys/i386/conf directory, you need to run the following command: # /usr/sbin/config AFNOG2005 Kernel build directory is ../compile/AFNOG2005 Don't forget to do a ``make depend'' Build a and install the kernel ------------------------------ This is very straightforward, as it's all controlled by 'make' # cd /usr/src/sys/i386/compile/AFNOG2005 # make depend # make # make install The first pre-processes the C programs to work out what the dependencies are (this is extra information used by the next stage). You then build the kernel, then install it. The original kernel directory, */boot/kernel*, is renamed to */boot/kernel.old*. The whole kernel build takes less than 10 minutes on modern hardware, but can take a lot longer on older systems. Now reboot to make your new kernel active: # reboot After rebooting, login and issue this command to check your kernel version: # uname -a Finding out about kernel configuration options ---------------------------------------------- In the directory /usr/src/sys/i386/conf directory you will find a file called 'NOTES'. This contains a lot of the options which aren't used in the GENERIC kernel, complete with comments. You can also generate a list of all possible configuration options (but without comments): # cd /usr/src/sys/i386/conf # make LINT # less LINT