Building Linux Kernel - - - > An Insight for Beginners

In this posting I’m trying to intend a brief introduction to building Linux kernels. Commands you should type are marked in bold-face

* Make sure /usr/src/linux is a link that points to the kernel directory that you are trying to compile
* Apply any patches that you have first: cd /usr/src/linux; patch -s -p1 < patchfile (where patchfile is the patch to be applied). Do this for each patch that needs to be applied.
* Configure the kernel. There are three ways to do this:
o make xconfig This is the easiest way to configure kernels if you’re using X windows. This uses a Tcl/Tk interface to prompt you for kernel options.
o make menuconfig This configure script uses a text menus to prompt you for kernel options.
o make config This method just asks questions one right after another with no real way to back up if you mess up other than starting over again.
After configuring the kernel once, those settings are saved for the next time you configure the kernel.
* Make the dependencies and clean out old object files with make dep; make clean
* Edit the Makefile and uncomment the INSTALL_PATH line, setting it to the directory where you want the kernel installed. When installing new kernels, choose an appropriate name for the new kernel and (we use directories inside /kernels/ to keep things clean). Make sure that the directory for the new kernel already exists. This path must be referred to in lilo.conf (in the next step).
* If you are creating a new kernel, edit /etc/lilo.conf adding a new 4 line entry with the new kernel’s information. Normally, after editing /etc/lilo.conf, you should run /sbin/lilo to recreate the boot information. Fortunately, the kernel Makefile will automatically run lilo for you (if you use make install).

image /kernels/<kernel-name>/vmlinuz
root = /dev/<main partition>
label = <lilo prompt name>
read-only

The <main partition> should be specified for one of the other kernels already installed on the system. The <lilo prompt name> must be unique.
* Type make install in the kernel’s top-level directory to build and install the kernel in the directory you specified in the Makefile.
* Examine the final steps of the make checking that the kernel was installed correctly and lilo ran without errors. IF LILO FAILED TO RUN CORRECTLY, DO NOT REBOOT THE MACHINE UNTIL YOU HAVE CORRECTED THE PROBLEM AND RERUN /sbin/lilo MANUALLY. IF YOU DO NOT, THE SYSTEM MAY BE UNABLE TO BOOT
* Reboot the machine after checking to make sure no one is logged on. Always sync the disks before rebooting with sync;sync;reboot

Once you have built a kernel for the first time future builds can be accomplished merely by typing make install in the top-level directory (/usr/src/linux). If you ever need to reconfigure a kernel, you will need to remake the dependencies and rebuild the entire source with make dep; make clean. Please send me any comments or suggestions for this document.

“In a world without fences, who the hell needs GATES…?”
Lans “The Lince” Ignatius
BLUG - R.E.C. Surat(1996)

Leave a Reply

You must be logged in to post a comment.