Step 3: Compile the Code


Step 3: Compile the Code

To compile your kernel, you first need to convert the kernel source code files into object code with the gcc compiler, using the make utility.

If you are using the 2.4 kernel supplied with this book, start with the make dep command to build the kernel module dependencies. However, you can skip this step if you are compiling a kernel from the 2.6 series.

Also, you must clean the kernel source tree regardless of which version of the kernel you are using, whether you are building a modular or monolithic kernel, or whether you are patching, upgrading, or compiling a new kernel. Use the make clean command, which will clean the kernel source tree and remove any temporary files that were left behind by a previous kernel compilation.

Once the kernel source tree is clean, you are ready to tell the gcc compiler to build a new kernel with the make bzImage command; then, if you are building a modular kernel, you'll need to add the make modules and make modules_install commands to build and install the kernel modules into the /lib/modules directory.

To store the lengthy output of the compilation commands in a file, precede the make commands with the nohup command, which automatically redirects output to a file named nohup.out. If you have difficulty compiling the kernel, you can enter each make command separately and examine the output of the nohup.out file after each command completes to try and locate the source of the problem. In the following example, all of the make commands are combined into one command to save keystrokes.

 #cd /usr/src/linux #nohup make dep clean bzImage modules modules_install 

Note 

If you are building a monolithic kernel, simply leave off the modules modules_install arguments, and if you are building a 2.6 kernel, leave off the dep argument

Make sure that the kernel compiles successfully by looking at the end of the nohup.out file with this command:

 #tail nohup.out 

If you see error messages at the end of this file, examine earlier lines in the file until you locate the start of the problem. If the nohup.out file does not end with an error message, you should now have a file called bzImage located in the /usr/src/linux/arch/*/boot (where * is the name of your hardware architecture). For example, if you are using Intel hardware the compiled kernel is now in the file /usr/src/linux/arch/i386/boot/bzImage. You are now ready to install your new kernel.



The Linux Enterprise Cluster. Build a Highly Available Cluster with Commodity Hardware and Free Software
Linux Enterprise Cluster: Build a Highly Available Cluster with Commodity Hardware and Free Software
ISBN: 1593270364
EAN: 2147483647
Year: 2003
Pages: 219
Authors: Karl Kopper

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net