Tina
This HOWTO describes how to compile and install the Linux kernel on Debian systems. The method described in this HOWTO is just one of several approaches one can use and does not claim neither to be the best nor the most effective way to compile the kernel. Although the described method should be safe it's always a good idea to make a backup of important data before doing major changes to the system. This HOWTO is licensed under the terms of the GNU Free Documentation License. It has been written in the hope that it will be useful to the community but it comes with no warranty; use it at your own risk.
Debian GNU/ Linux has a lot of advantages, one of them being the precompiled kernels. This enable users to easily install new kernels without the need to compile. However, sometimes it's necessary to compile a custom kernel and it can seem like a rather daunting task for beginners. But compiling your own kernel is actually not that hard and it is a useful skill to master.
Preparation:
First you'll need to install the necessary tools. You might have some or all of these already installed on your system:
Code: Select all
# apt-get install kernel-package ncurses-dev bzip2 module-init-tools initrd-tools procps
Getting the kernel source:
There are basically two ways to get the kernel source.
From Debian repositories
From kernel.org
From the Debian repositories:
The preferred method of acquiring the kernel source is from the Debian repositories simply by installing it through apt-get:
Code: Select all
# apt-get install kernel-source-x.x.x
Code: Select all
# apt-get install kernel-source-2.4.27
Code: Select all
# apt-get install linux-source-2.6.15
/usr/src/linux-source-2.6.15.tar.bz2
From kernel.org:
The standard kernel is released on http://www.kernel.org/. Kernel.org holds all kernels that has been released plus all patches. If you require the absolute bleeding edge kernel this is the place to get it. Navigate to the kernel you wish to install and download the bz2 archive. For example the kernel 2.6.15.1 will be downloaded from the URL:
http://www.kernel.org/pub/linux/kernel/ ... .1.tar.bz2
If you downloaded the bz2 archive to your home directory or some temporary folder move it, as root, to /usr/src/
Unpack and configure the kernel:
Now you have the compressed kernel source in your /usr/src/ directory and it's time to unpack it. From now on I'll use the 2.6.15 as my sample kernel through out this howto. You will of course have to substitute that for your kernel.
Change to /usr/src/ (cd /usr/src)
Do
Code: Select all
# ls -la
-rw-r--r-- 1 root root 39315716 2006-03-06 12:32 linux-source-2.6.15.tar.bz2
So let us unpack our kernel source by entering:
Code: Select all
# tar xjf linux-source-2.6.15.tar.bz2
Code: Select all
# cd linux-source-2.6.15
Use
Code: Select all
# make menuconfig
Code: Select all
# make xconfig
Edit: xconfig require a QT library. If you get an error you probably don't have it installed. Install it with
Code: Select all
# apt-get install libqt3-mt-dev
Both do the same job so it's just a matter of taste.
This will bring up the kernel configuration screen.
If you already have a working configuration you only want to tweak a bit you can load it by scrolling down to “Load an alternative configuration file” and enter the path (normally /boot/config.x.x.x).
Now you can scroll up and down, changing the settings you want to change. There is a vast amount of things to include in the kernel but that is outside the scope of this howto. There are however lots of information about the Linux kernel both on the web and in books.
Compile and install the new kernel
When you are done configuring the kernel you can use esc to exit. Answer yes to save the new configuration. To start compiling the kernel issue the following commands:
Note: make dep for 2.4.x kernels only!
Code: Select all
# make dep
Code: Select all
# make-kpkg clean
# make-kpkg kernel_image
Code: Select all
# make-kpkg --revision=custom.0.1 kernel_image
Now you should see a lot of text flickering by on your screen. This is the compile in progress. Please note that compiling the kernel takes quite some time depending on your system (approx 30-60 minutes give or take) so be patient. And if everything goes well you are rewarded with a nice .deb file in your /usr/src/ that will look something like:
/usr/src/kernel-image-2.6.15_i386.deb
Install the kernel:
Code: Select all
# dpkg -i kernel-image-2.6.15_i386.deb
Code: Select all
# cd /boot/
# mkinitrd -o /boot/initrd.img-2.6.15 2.6.15
Code: Select all
title Debian GNU/Linux, kernel 2.6.15-1-486 (on /dev/hda1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-1-486 root=/dev/hda1 ro
initrd /boot/initrd.img-2.6.15-1-486
savedefault
boot
Remember that your old kernel is preserved so if your new kernel for some reason don't work you can always boot your old kernel and investigate what went wrong.
Enjoy!
Tina
Edit: Adapted to new Etch release.