~  CHAPTER 10:  COMPILING THE LINUX KERNEL  ~

 

 

 

One of Linux’s greatest strengths is that its source code is available to anyone who wished to

peer inside. 

 

The GNU GPL (general public license) under which Linux is distributed even allows you to tinker

with the source code and distribute your changes!

 

NOTE:  Linux’s core development group is geographically quite diverse.  Key people include

Alan Cox in the U.K., Alexey Kuznetsov in Moscow, and Linus himself in Northern California’s

Silicon Valley. 

 

If you see code that has a ca after it for example 2.4.4 ca  this may mean that Alan Cox has signed

it off.

 

            CAUTION:  The kernel is the first thing that loads when a Linux system is

            Booted.  If the kernel doesn’t work right, it’s unlikely that the rest of the

            System will boot.  Be sure to have an emergency boot disk handy in case

            You need to revert to an old configuration. 

 

                                    uname^-r 

 

Will give you the version number of the operating system.

 

            2.4.2 –2  The 4 is even so the operating system is stable.  If it was 2.5.2-2

            This would signify an experimental system, and it should be installed with

            Caution.  If you have 2.4.2-2ac The initials are for Alan Cox.

 

 

What exactly is a Kernel?

 

Te kernel of any operating system is the core of all the system’s software.  The only thing more

fundamental that the kernel is the hardware itself.

 

The kernel has many jobs.  The essence of its work is to abstract the underlying hardware from

the software and provide a running environment for application software.

 

 

Advantage of having a kernel:

 

  • Advantage of having a Kernel:  It loads faster, direct access to the Hardware

 

  • Disadvantage of having a Kernel:  The module is put in RAM, and it uses RAM.

 

  • Uptimes:  the length of time in between reboots.

 

 

 

 

======================================================================

 

linux10.html                                                    PAGE 2                                                      2002/07/18

 

 

 

Finding Kernal Source Code

 

 

http://www.kernel.org.  The kernel is compressed once compiled so you can fit it on a floppy.

 

 

Upacking the Kernel

 

 

Use the tar command. 

 

 

Building the Kernel   (May be on exam)

 

 

So now you have an unpacked kernel tree just waiting to be configured.

 

The first step in building the kernel is configuring its features.  Usually your desired feature list will

be based on whatever hardware you need to support.  The following command will list all

hardware connected to the system via the PCI bus:

 

cat^/poc/pci

 

Next, use this command to invoke the make utility.  Not on version 7.0.

 

make config

     OR

make menuconfig

 

With the module system, the kernel designers have created a way for parts of the kernel, called

modules, to be dynamically loaded and unloaded from the kernel as needed.

 

 

Compiling the Kernel

 

The first stage creates the dependency tree, which is a fancy way of saying that the system

determines which files need to be compiled and which can be ignored.

 

make^dep;make^clean;make^zImage;make^modules

           

 

 

 

 

======================================================================

 

linux10.html                                                    PAGE 3                                                      2002/07/18

 

 

 

Installing the Kernel 

 

Assuming you have a PC and are working out of the /usr/src/linux directory, the compiled kernel

will be called /usr/src/linux/arch/i386/boot/zImage.        

 

make^modules_install.

 

The lilo output contains the boot options told to it by the /etc/lilo.conf.  The default kernel that will

boot is the very first one (with the *next to it).  reboot and let it fly!

 

 

Patching the Kernel

 

Like any other operating system, Linux gets upgrades to fix bugs, improve performance, and add

new features.

 

Think of patches as comparable to a Windows HotFix or service pack.  By itself, it’s useless; put

when added to an existing version of Windows, you (hopefully) get an improved product.

 

Downloading and Unpacking Patches

 

Patch files are located in the same directory from which the kernel is downloaded.  This applies to

each major release of Linux, to the patch to update 2.4.0-test9 to 2.4.0-test10 is located in the

/pub/linux/kernel/v2.4/

 

Summary:

 

  •   Compiling the kernel is a significant but straightforward process.
  •   The Linux development community has provided excellent tools that make the process

as painless as possible.

  •   For programmers curious about the kernel’s innards, many references are available.