Kernel Compile

Kernel Sources


Before you can compile a kernel, or recompile your current kernel, you will need to have the kernel sources, and maybe a few other packages.

You can download the latest kernel source (and all the previous kernels) from kernel.org. They offer ftp and http downloads. The latest kernel sources tend to be rather large, about 16 mb, and are in the either gzip or bzip2 compressed format. You can also get PGP signed sources for verification. Additionally, you will also find kernel patches here. Kernel patches are significantly smaller, usually no more than 3 mb in size. Kernel patches allow you to upgrade to the next kernel revision release without having to download the entire source for the new kernel.


The kernel from your distro

Depending on what type of install you do for your distribution, you may or may not have the kernel sources. The kernel sources are located in /usr/src. You can use your package manager program to determine whether you have the kernel sources installed.

A note about kernel patches

It is recommend that you do not attempt to patch a kernel that provided by your distribution. Distributions like RedHat, Suse, and Mandrake tend to include customized kernels which may include enhancements not found in the stock kernel at kernel.org. You can either wait until your distribution provides and patch for your current kernel, or an update to the next kernel. Otherwise, you will have to download the kernel sources for the version you want to use.

You cannot switch to a major or minor kernel version (see explanation below of major and minor numbers below) by applying a patch. You will have to download the kernel sources to switch between kernel versions.


Kernel Versions and Revisions: Major and Minor Number Explanation

The kernel number system is pretty straight forward. It consists of three numbers: The Major number, Minor number, and revision number; and is expressed in this fashion:

kernel-2.2-16
In this example, the Major number is 2, the Minor number is 2, and the Revision is 16. The Major number seldom changes unless the kernel is rewritten in a big way. Currently, the kernel is at Major number 2.

The Minor number changes with a bit more frequency, but may last for years. The current Minor number is 4. Minor number changes occur when there is significant innovation into the kernel that seperates it enough from the current kernel Minor number version. For instance, the inclusion of USB, improved networking, improved memory handling, increased multi-processor support, and other enhancements all lead to the change from Minor number 2.2 to 2.4 kernels.

Another point of interest regarding the Minor number is that even Minor numbered kernels are considered stable, production kernels; while odd Minor numbered kernels are developmental kernels. Developmental kernels should not be used on mission critical systems since they are not as stable as production level kernels. Developmental kernels eventually roll into the next Minor number production kernel release. For instance, developmental kernel 2.3-x rolled over into production kernel 2.4. Developmental kernels may be necessary to support more current hardware and innovation. Some disributions will take the new, more stable pieces of the developmental kernel and merge them into a production kernel, thus creating their own, enhanced version of the kernel. It is this reason that one should not use patches from kernel.org to patch such kernels, but wait for one's distribution to put out a patch or update.

Finally, the last number is the Revision, or patch level. This number indicates that there has been some minor tweaks, bug fixes, security enhancements, etc. added to the kernel. One has the choice of either downloading the entire new kernel, or just the patch to update the current kernel to the next revision. Please note that in order to apply kernel patches, you must do so in order, without skipping a patch release. That is, if you are currently runnning kernel 2.2-14 and the Revision 18 is released, you must first download and apply Revision patches 15, 16, 17, and then 18 in that order.


<-Back (Why)   TOC    Next (Need) ->