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
- Make sure you have a working emergency boot disk. Oh, working means you have tried it and it works :)
- Determine what you are using the machine for and what services are required
- Gather information. You must know things like network card model, cpu, drive/cd-rom interface type etc.
- Get the latest kernel source. You can find it at The Linux Kernel Archives
- Get the latest security patch. You can find it at The Openwall Project
- Clean up the old directories. See the Clean Up section below
- 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
- make config
- make dep
- make clean
- make zImage
OR
- make config
- 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).
- It is a good idea to go through the choices, and read the descriptions, at least one before making your final selections.
- If you are simply optimizing your workstation, you probably want to answer no to the first question "Prompt for Experimental".
- If you are planning to use modules be sure to answer Yes to:
"Enable loadable module support?"
- The currently selected option, as indicated in Uppercase, will remain if you just hi enter.
- If you want to quit the make config process, just use crt-alt-del.
You will loose your current work. It is usually better just to "keep hitting enter" till your done, then start over with you resent choices already selected.
- One down side of the config method is there is no "undo".
You may prefer to try Menu Config or X Config replacing config
as in make menuconfig or make xconfig.
As usual, I think you should learn your way around without these enhanced interfaces as they are not always going to be available on every machine.
Make and Install Modules (if necessary)
From /usr/src/linux run:
- make modules
- make modules_install
Install the new Kernel
- copy System.map and zImage to the /boot dir:
- from /usr/src/linux, cp ./System.map /boot/System.map-2.2.16 (or whatever)
cp ./arch/i386/boot/zImage /boot/vmlinuz-2.2.16 (or whatever)
- create symbolic links for above:
- cd /boot
ln -sf vmlinuz-2.2.16 vmlinuz
ln -sf System.map-2.2.16 System.map
- Tell lilo about the changes:
- edit the lilo confg file so it references the new kernel:
vi /etc/lilo.conf
- 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
- it's safer after a trial reboot
- remove old stuff from /boot and remove some stuff from /usr/src if desired.
Reboot
Page Created by Pete Nesbitt, September 2000
Minor update August 2001