Pointers for Compiling the Linux Kernel

NFS, ISO & Windows



Why you should Re-Compile the Kernel

Performance and Security are the two main reasons to re-compile the kernel.
Although the latest kernel is now optimized for a P-II (older ones are set for a 486), it is not likely optimized for your system.
In order to make sure most features work for most machines, the kernel defaults to supporting much more than most systems have. It makes sence to reduce the kernel to support only features and resources you want or need. Ideally, you want to avoid "Module Support" if possible.

Note: use can use the "?" for help on any item during the config steps (explained below).

Things to do BEFORE you Compile
  1. Make sure you have a working emergency boot disk. Oh, working means you have tried it and it works :)
  2. Determine what you are using the machine for and what services are required
  3. Gather information. You must know things like network card model, cpu, drive/cd-rom interface type etc.
  4. Get the latest kernel source. You can find it at The Linux Kernel Archives
  5. Get the latest security patch. You can find it at The Openwall Project
  6. Clean up the old directories. See the Clean Up section below
  7. Clean up source code by running make mrproper from the /src/usr/linux directory (or where ever)


Pre Compile Clean-up

remove old source, old reference directories



Compile the Linux Kernel

There are four commands I use to make the kernel. I'm sure there are other ways to do this.
They can be run individually, or the last three could be combined into a single command line set.
You MUST be in the source directory, typically /usr/src/linux

  1. make config
  2. make dep
  3. make clean
  4. make zImage
OR
  1. make config
  2. make dep&&make clean&&make zImage

make config is the interactive part of the process. This when the you select what components will be included with the core operating system.
These components can be built in as part of the kernel code or in the form a module. A module is loaded as needed so it is a good choice for supporting rarely used devices. Also, it can be handy for things like ISA based systems, when you may need to adjust IRQ or IO settings as generally, they can be passed arguments through a config file.

However, at the cost of versatility, you can build a monolithic kernel without module support. This method can provide increased performance and tighter security (no kernel modules can be loaded by an intruder).



Make and Install Modules (if necessary)

From /usr/src/linux run:
  1. make modules
  2. make modules_install


Install the new Kernel

  1. copy System.map and zImage to the /boot dir:
  2. create symbolic links for above:
  3. Tell lilo about the changes:
    1. edit the lilo confg file so it references the new kernel:
      vi /etc/lilo.conf
    2. run the the lilo utility to update changes made to the lilo.conf file:
      lilo -v (you don't really need the -v)


Post Compile Clean Up


Reboot

Page Created by Pete Nesbitt, September 2000
Minor update August 2001