Installing and Upgrading the Linux Kernel:
A Quick Guide.
Alistair Ross [email protected]
v1.0, Tuesday, April 17, 2016
This quick guide was created for the following reasons:
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# cd /usr/src/
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
bash# tar zxvf kernel-[version_number_here].tar.gz
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# 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:
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!