Kernel Compiling

This is intended to be brief instructions for the impatient. Please refer to the Linux Kernel HOWTO (which is also cached locally) for more information.

Linux kernels are numbered with a major and minor number and patch levels. For example, in 2.4.1, the major number is 2, the minor number is 4, and the patch level is 1. The minor number is even in stable kernels and odd in development kernels. Use what you want. You can find out what version of the kernel you are using by typing uname -a.

Why might you want to compile your own kernel? Because you want a customized kernel. You may need support for hardware that isn't compiled into the default kernel or you may just want to be on the bleeding edge and have the newest kernel. You may want to take out support for hardware that you don't use to have a smaller and more efficient kernel. Or, as is sometimes the case, you may need to upgrade your kernel version for security reasons. Still, sometimes you might not need to compile your kernel. You can install a precompiled kernel, use a kernel package, or just add a module to your kernel. Or, if you just wanted to modify the root device or video mode, you can use the rdev command.

First you need to obtain your kernel source. You can ftp it from or one of its mirrors. Kernel source is available on-campus via ftp at Once you get it, you need to extract it in the directory /usr/src, so cd /usr/src before you ftp.
gzip -cd linux-2.n.xx.tar.gz | tar xfv -
bzip2 -cd linux=2.n.xx.tar.bz2 | tar xfv -
should do the trick.

If are patching kernel source to a newer version, you must apply all patches in order using the patch program. Instead of piping the output of gzip or bzip2 to tar, pipe it to "patch -p0" for each patch.

Change directories to the directory where the kernel source was untarred, usually "linux" (cd linux). Read the file called README. Now you are ready to configure your kernel, using make config, make menuconfig, or make xconfig. I use make menuconfig. (Debian Potato users may find themselves missing libncurses5-dev which is needed to run menuconfig. Simply apt-get install libncurses5-dev to fix this problem.) You may want to save your kernel configuration to an alternate file that has the date included in the file name.

Once you have configured the kernel,
make dep; make clean; make bzImage
to compile the source. If you want to know what that does, read that README or the HOWTO. If you have any modules, you will also need to execute
make modules; make modules_install
to make them.

After some amount of time, your computer should stop compiling C code and leave you with a kernel image in "/usr/src/linux/arch/i386/boot" (if your architecture is i386). You need tell lilo to use this new kernel. Backup your old kernel image. You might even consider putting it and/or your new kernel on a floppy using mkboot or the dd command. Instead of modifying /etc/lilo.conf, I usually just create a symbolic link. Here's what I do:
cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.n.XX;
rm /vmlinuz; ln -s /boot/vmlinuz-2.n.XX /vmlinuz; lilo

And then, if all went well, shutdown -r now should reboot the system with the new kernel.