From time to time you may need to install the Linux (the kernel) manually, this may be to get some new feature you want, or just to see what it’s like.
Okay firstly you’ll have to download the kernel sources from Kernel.org and download the compressed archive, which will be named linux-2.6.”some_number”.tar.bz2 – higher the number, newer the kernel
Download the archive, use wget or your browser’s download manager for this.
The ‘classic’ place to put kernel sources is in /usr/src – but you don’t need to do this (it is recommended that you don’t), you could have the sources in your home directory if you want, or any other place (well except /tmp or /var/tmp since they may go missing if you do that).
Now move the download to where you want it (e.g. /usr/src or /home/user/kernel) directory with e.g.
mv /home/user/linux-2.6.16.tar.bz2 /where/you/want/it
replace /where/you/want/it with where you wish to install the kernel – Note: if you are moving it to any place that is not in your home directory you’ll have to have super-user powers given by su or sudo.
Note: For this article we’re using the 2.6.16 version of the kernel in our examples, as the kernel is updated with newer versions remember to make the substitutions yourself.
Now to prepare before the configuration and compilation.
# mount /boot # cd /where/the/kernel/is # tar xjvf linux-2.6.16.tar.bz2 # cd linux-2.6.16
mount /boot will mount the boot partition if it is not already mounted (you may need superuser powers for this).
Now to make sure the kernel tree is clean:
Now you need to configure the kernel, it really helps to know about some of your hardware specs and what you want from your kernel at this point. Commands such as lspci may help you to find information on your hardware, such as chipset names and manufacturers – this will help you select drivers for network cards, sound cards and disk drives.
To configure the kernel you have many choices, the four most used are: make config, make menuconfig, make xconfig or make gconfig. The one used most often is make menuconfig which is a ncurses based configuration tool, make xconfig gives you a nice Qt-based interface, make gconfig gives a GTK based interface and make config gives you a readline-based text interface.
now a menu will appear, go through each menu picking out what features you want.
(M) – shows the feature will be compiled as a module;
(X) – shows the feature will be compiled within the kernel; (not using modules will speed up your computer’s boot process, as it will not have to find the right modules then.)
Usage: When using make menuconfig, the up and down arrow keys navigate through the items, Enter selects. The left and right arrow keys navigate through the bottom “buttons” (like Help, Select or Exit). ESCape goes to the parent menu. ‘Y’ selects an item, ‘M’ selects and item as module, ‘N’ de-selects an item, or you can use the spacebar to scroll through these selection options. Pressing ‘H’ will give a help page if you are unsure of what the feature does.
Once you have picked out the features you want, save and exit from the configurator. It is best to know your computer’s components, so you select the right drivers first try.
Now type in the following commands:
This will build the kernel as you wish.
Now, wherever the kernel sources are on your system you must be superuser to install the kernel:
make modules_install && make install
This will install the modules to the correct directory, copy over the kernel image, the System.map file and the config file to the /boot directory. It will also symlink /boot/vmlinuz to the new kernel image.
Next you will have to add a new kernel entry to your bootloader. Two most commonly used bootloaders are GrUB and LILO, and the next step depends on which one you use.
Adding to the GRUB bootloader
Now you have a new kernel you’ll want to boot using it, so you must add it to your bootloader. So you must edit your grub.conf or menu.lst file within /boot/grub (the file depends on the distribution of GNU/Linux you have).
Now you must add a stanza for the new kernel, it’ll look something like this: (replace LINUX_VERSION with the appropriate numbers e.g. 188.8.131.52 and replace ROOT_PARTITION with whatever you root partition is e.g. /dev/hda3)
title GNU/Linux root (hd0,1) #If Linux calls /boot /dev/hda2. If it calls it /dev/hdb3, then (hd1,2). /dev/hda6=(hd0,5)....
kernel /vmlinuz-LINUX_VERSION root=ROOT_PARTITION
#initrd /initrd-LINUX_VERSION.img # if you use an initrd remove the # at the beginning of the line
Adding to the LILO bootloader
If you are using the Linux Loader (LILO) as your bootloader you’ll have to add a new kernel to it slightly differently than one does to GrUB.
You must edit the /etc/lilo.conf file. Open it up in your favorite editor and add a stanza that looks something like this (replace LINUX_VERSION with appropriate version numbers e.g. 184.108.40.206 and replace /dev/hdxx with the location of the root partition e.g. /hev/hda3):
image = /boot/vmlinuz-LINUX_VERSION #Location of the kernel image label = GNU/Linux # Name given (for lilo boot menu) root = /dev/hdxx # Location of root partition
Once you have edited the file and are happy with it, save it and run
/sbin/lilo – This is important or you’ll have trouble booting.
Notes on kernel naming: The kernel name doesn’t have to be vmlinuz-LINUX_VERSION, you can use just vmlinuz if you only use one Linux-based OS. /boot/vmlinuz is a symlink to the last kernel version you installed usingmake install.
If you put the kernel image name as vmlinuz it will boot the latest kernel each time you install it – without you having to edit the bootloaders configuration file.
Note on patching up your kernel to the latest version
You will not always want to go through the hassle of downloading the latest kernel sources, if say, you want to upgrade from version 2.6.16 to 220.127.116.11 you can use the patch files from www.kernel.org, the latest stable patches will be linked after “The latest stable version of the Linux kernel is:”. Download the patch to the same place as you have the kernel sources. Then follow the following commands:
cd /place/where/kernel/sources/are ls
The output of ls should be something like this:
cd linux-2.6.16 bzip2 -dc ../patch-18.104.22.168.bz2 | patch -p1
Your kernel should now be patched up to the latest version.
If you are on kernel version 2.6.16 and want to upgrade to 22.214.171.124, firstly apply the patch for 126.96.36.199, then the patch for 188.8.131.52.
Catchup on your patches with ketchup
There is a script available known as ketchup that helps users download the latest patches for their kernel.
Once one has ketchup installed do the following to update your kernel patches:
cd /where/the/kernel/is/linux-2.6.16 (version may be different) ketchup -m
This will tell you which version of the kernel you currently have;
will update your kernel to the latest patchset, by downloading and installing each patch.
You may want to install a specific patch tree such as Andrew Mortons ”’mm”’ patchset, you should use the following syntax:
ketchup -s 2.6-mm
If you have compiled modules into your kernel you’ll have to load them.
To load them manually:
If you wish to load the modules automatically at boot please refer to your distributions documentation, as it tends to vary from distribution to distribution.
There is an option you can compile into the kernel which allows it to load some modules automatically as parts of the kernel need them. The option is available in:
Loadable module support ---> [*] Automatic kernel module loading
We hope you find this article useful.
This is not a replacement for the kernel documentation in the kernel sources, which we recommed you also read.
Use this tutorial at your own risk – we will not be liable for any damage caused.
a thing, dylunio, stojic, valan and members of the Libervis Network Community.
A more up to date version of this document is to be maintained on the Libervis Wiki.