Installing and Upgrading the Linux Kernel:
A Quick Guide.


Alistair Ross [email protected]

v1.0, Tuesday, April 17, 2001


  This quick guide was created for the following reasons:
  • Whilst the Linux Kernel HOWTO at The Linux Documentation Project is an in-depth and handy guide, there is 14 sections and over 20 pages of reading to be had to know how to fully upgrade/install a new kernel. The guide is good because it teaches you all the ins and outs of the procedure, and if you want to know every last detail about upgrading/installing your kernel you should go there. Points like What does the kernel do, anyway? are not covered in this guide
  • This guide is intended to be a run-down almost 'tick off' list that will allow you to quickly and easily upgrade or install a new linux kernel onto an Intel (x86) based computer. This guide does not cover upgrading on platforms such as Alpha, S/390, PPC or others. Neither does the Kernel-HOWTO, so if you own one of those processors; whilst the process of upgrading/installing is similar, you won't be able to follow this guide word for word and expect it to work. I'm sorry about that, but I don't have anything else apart from a PC to test it upon, donations of other hardware to do this with will be welcomed!
  • If you have never upgraded or compiled a kernel before, and don't want to know all the details about being a kernel guru, just how to upgrade or install, then this is for you.
  • If you've gotten ABC program, a tarball or RPM or whatever, and it says to you: You need Kernel-XYZ-version to run this, and you really wanna run ABC, so you decide to pucker up and upgrade your kernel, then this is for you.
  • You've just got hold of this new USB device (or any unsupported device with your current kernel), and found out that Kernel XYZ won't support it, and you need to upgrade to Kernel ZYX to use it, then this is for you.

NOTE: Do all of the following as root! - ie: do a "su - " to become root before doing any of this.

1. Download the latest version of the Linux kernel from ftp.kernel.org or one of it's mirrors. You can find out what the latest stable version of the kernel is by looking at www.kernel.org. At the bottom of the page, there is a box indicating the latest version.
The latest version (at time of writing, 2.4.3) is around 26mb big, so if you have a slow connection be prepared for a little wait.
2. When downloaded, make a folder that goes by the name of the kernel version in /usr/src, so for example, if I downloaded Kernel 2.4.3, i would make the folder /usr/src/linux-2.4.3.
Now enter /usr/src and look to see if there is already a folder in there called linux. There probably is, and it's probably a symlink to the existing kernel version. If that's the case, remove that symlink and replace it with a symlink to the new kernel folder. Once done, move the newly downloaded kernel tarball into the kernel folder, ie:
    bash# mkdir /usr/src/linux-2.4.3
    bash# cd /usr/src/
    bash# ls
        linux
        linux-2.2.16
        linux-2.4.3
    bash# rm linux
    bash# ln -s linux-2.4.3 linux
    bash# mv /home/bob/linux-2.4.3.tar.gz /usr/src/linux-2.4.3
3. Untar/gz the file as root by doing the following:
    bash# cd /usr/src/linux
    bash# tar zxvf kernel-[version_number_here].tar.gz

The kernel will then be untarred into a folder called linux.

4. Enter the linux folder and if X is running and you are at an xterm or something, type the following: make xconfig. Doing that brings up a nice GUI that helps you configure your new kernel. If you don't have access to X or can't be bothered with it, use the Ncurses menu driven console kernel configuration tool, do this by typing make menuconfig, remember you need ncurses for this, if you havent got it installed it wont work, but unless you have a *seriously* crappy distro of linux, you'll have ncurses. If you're really up the creek and you don't have X or ncurses, you can fall back to the entirely user-unfriendly text based installer, type make config to start the questions rolling

5.Whatever interface you chose in the last step, you'll get asked the same questions. Some will relate to disks, ie: IDE support, some will relate to PCI/ISA cards, and some will relate to the motherboard. As there are a lot of steps in this menu, you're on your own for this one, but thankfully from version 2.0.1 of the Linux kernel, there is a help button, which generally gives up to date help for each feature of the kernel options.
It is imperative that you choose the correct options, as your system will rely on these when operating later.
When you've gone over all the options and double checked they're all ok, save your settings, and maybe save them to a file also, just in case you wanna go back and use them again later. Anyways, save and exit from the configurator.

6. Type in make dep and let it run through all of it's compiling

7. Type in make clean to clean up all of the object files it made

8. After making the dependency checks, and tidying up the object files, it's time to make our kernel, hold on to your hat, or what little hair you have left and key in make bzImage
This sucker takes some time, and will take a lifetime on a 386 or 486 based PC, just to let you know!
When it's finished, it's up to you whether you wanna make a boot disk image, just in case you screw things up, I'd also consider doing a make bzdisk to make a boot disk of the new kernel

9. Go back to wherever you got your kernel from and download modutils-[the-kernel-version-here].tar.gz

10. Unpack the modutils tarball with tar zxvf modultils-version.tar.gz in a directory that is close or inside the /usr/src/linux folder. Personally, i'd make a folder inside /usr/src/linux called modutils and untar it in there.

11.Read the README file that you extract from the modutils tarball and install it, which is usually done by doing something like make install. When that's done, you should find you have the programs insmod, rmmod, ksyms, lsmod, genksyms, modprobe and depmod in the /sbin folder.

12.back in the /usr/src/linux folder, key in make modules.

13.Step 12 should take no more than a few minutes, so after that key in make modules_install

14.After you've got the modules in place (/lib/modules), it's now time to copy the compressed kernel to the boot area so that LILO can boot it. I'm assuming that you boot with LILO, so this is what to do:
locate the bzImage file that you made in step 8, and pop it into a newly made directory in /boot, with the kernel version as it's name, it's common practice to rename bzImage to vmlinuz in the process, ie:
    bash# mkdir /boot/linux-2.4.3
    bash# cp /usr/src/linux/arch/i386/bzImage /boot/linux-2.4.3/vmlinuz

15.Assuming that you already have a working kernel running, and that you are using LILO to boot your linux box, go into /etc and edit your lilo.conf, adding a second linux kernel to boot from. Here is an example:
Original lilo.conf New lilo.conf
boot="/dev/hda"
map=/boot/map
install=/boot/boot.b
prompt
timeout="100"
message=/boot/message
default=linux-2.2.16

#Kernel 2.2.16 image HERE
image="/boot/vmlinuz-2.2.16-22"
       label="linux-2.2.16"
       read-only
       root="/dev/hdc1"
boot="/dev/hda"
map=/boot/map
install=/boot/boot.b
prompt
timeout="100"
message=/boot/message
default=linux-2.2.16

#Kernel 2.2.16 image HERE
image="/boot/vmlinuz-2.2.16-22"
       label="linux-2.2.16"
       read-only
       root="/dev/hdc1"

#Kernel 2.4.3 image HERE
image="/boot/2.4.3/vmlinuz"
       label="linux-2.4"
       read-only
       root="/dev/hdc1"


16. When you've figured out how to add your new kernel entry to your lilo.conf file and you're damn sure that you got it right, just type in lilo to replace the MBR with the new lilo boot data
If it's a sucess, you'll soon know, if it isn't lilo will present you with a reasonably helpful error message.

17. If lilo has been a sucess, the modules are in /lib/modules/kernel-2.4.3 (or whatever kernel version you've just put in) and the new /boot folder with your new kernel is in place is all there, it's time to issue that magical command: reboot and see if your new kernel holds together.
When lilo comes up, you're probably used to selecting or giving it the name of your default linux label (in my case that was linux-2.2.16), so make sure that you don't load your old kernel here, load your new one, by making sure you select or type the name of your new kernel label (as specified in lilo.conf). After you key it in, hit return and watch the boot messages like a hawk for any errors. If none, and you're running your new kernel (testable by typing uname -a at the prompt), then congradulations, you've made a sucessfull upgrade, otherwise, you've probably gotta start from step 4 again: running the menu for the kernel configuration and choosing the right modules or software to load into the kernel.
The two main points of failure on a kernel upgrade or installation are configuring the kernel it's self (usually at make xconfig or whatever) or configuring lilo to boot your kernel. Either way, best of luck in getting it working!
HOME | LINKS |