Theory

The Linux kernel can be described with this diagram:

The kernel has the following responsibilities:

Getting the Kernel Source

The kernel sources can be gotten via http from http://www.kernel.org or via ftp from ftp://ftp.kernel.org. This site is the main distribution center for the sources.

There are various ways to get the sources, ie... netscape, ftp client, etc. The easiest method is to use the 'wget' program with this command:

% wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.2.tar.gz

This will grab the file 'linux-2.4.2.tar.gz' from www.kernel.org and deposit it in the current directory.

The kernel can be compiled anywhere on the system however by custom the location is in the /usr/src directory. So... just move the linux-2.4.2.tar.gz file to that directory. Before extracting the files you may have to rename the current linux directory name to something else... linux-old for example.

Right... now the uncompressing the extracting of the files can begin... type:

tar -zxvf linux-2.4.2.tar.gz

Everything will be extracted to the linux directory. Now one can either configure the kernel or add some extras via kernel patches.

Kernel Patches

Ideally when a new kernel is released it should contain all of the updates from contributing authors. However, sometimes for several reasons this is not the case:

Patches allow the user to try new technologies that aren't quite stable enough to be added to the stock kernel.

Redhat, Mandrake, and other distributions never ship a stock kernel as the main kernel image. A large number of patches are applied so to make the system more useable. Some examples would include:

The command for patching the kernel is:

% patch -p1 < patchfile

Configuring the Linux Kernel

After applying any patches the kernel build process needs to know what to build. Each configuration would be different all depending on what hardware needs to be supported and what general functions the machine will perform.

There are multiple ways to configure:

Sample entry for 'make xconfig':





Code maturity level options

Loadable module support

Processor Type

General Setup

Parallel port support

Block Devices

Networking Options

Telephony Support

ATA/IDE/MFM/RLL support

SCSI support

IEEE 1394 support (Firewire)

Network device support

IrDA support (infared)

Character Devices

Multimedia Devices

File Systems

Sound Support

USB support

Finally, when that is done don't forget to save the configuration.

Compiling and Installing Kernel and Modules

At this stage the kernel should be ready for compiling. The build options have been set and are kept in the .config file.

Commands:

The kernel is now built and the modules are in place however, the kernel image isn't where it's supposed to be

After compiling, the kernel image can be located in /usr/src/linux/arch/i386/boot. Just copy that to the root directory