Kernel compiling the Debian way


I have to admit that Debian eases some administrations tasks like the kernel compiling process. At first sight, the procedure looks similar to compiling a kernel in the old-fashioned way but what it makes it different is that you will end up with a Linux kernel in a .deb file, so it will be easier to install the same image kernel in other computers by just installing the .deb file.

Another advantage of compiling a kernel in Debian is you don’t have to worry about building the initramfs image file or changing your boot loader, because Debian does it for you automagically.

So, I think you might be interested in how to compile a kernel the Debian way, sol let’s see how to do it…

Requisites

Due to you are about to compile a kernel, you’ll need some files and compilers. You will also need ncurses to display dialog on a consoles, and for building the .deb file you will need the kernel-package utility. In Debian you can install all this by typing:

aptitude install build-essential libncurses5-dev kernel-package

Working directory

It’s common to use the /usr/src/ directory when compiling the kernel, drivers and modules. So, go to the /usr/src/ directory:

cd /usr/src/

Procedure

You’ll need to get the kernel’s sources to compile them. They can be got from your distro’s repositories or from kernel.org directly. In Debian by installing the following package you will get a tar file in the /usr/src/ directory:

aptitude install linux-source-2.6.30

If you want to download it from kernel.org it would be something like this:

wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.2.tar.bz2

Now unzip the tar file:

tar xjfv linux-2.6.32.2.tar.bz2
If the linux link exists from previous compilations, remove it:
rm linux
Now make a link to the unzipped directory. If you downloaded the sources from Debian it would be:
ln -s linux-source-2.6.30 linux

If you downloaded it from kernel.org, you have to type:

ln -s linux-2.6.32.2 linux

Go the linux directory:

cd linux

If you’ve compiled other kernels it’s a good idea to clean everything before starting to compile your new kernel:

make mrproper

Now proceed to set your kernel’s options. To do so, you can use make config (an interactive but annoying interface), make menuconfig (based on ncurses) or make xconfig (you’ll need X running).. I suggest to use the second option:

make menuconfig

After you have made you selection, choose Exit to write the .config file

The Debian way

Here is where things are different from the original procedure because you will compile your kernel and modules but the result of compilation will be a .deb file. Let’s say you want to compile a Linux image with its initramfs and headers files, the command and options to accomplish that is:

make-kpkg --revision lnv1 --initrd kernel_image kernel_headers

Where:

Option Description
--revision lnv1
Revision number for the .deb file
--initrd
Include initramfs image and its installation scripts
kernel_image
Generate a .deb file with a kernel image
kernel_header
Generate a .deb file with kernel's headers

In order to install your new compiled kernel just install the .deb file as follow:

dpkg -i /usr/src/linux-image-2.6.32.2-mundungus_lnv1_i386.deb

This will install the kernel and initrd images into the /boot directory and run update-grub utility automatically, so your new kernel image will be listed on grub’s menu next time you reboot your computer.

Share this:
  • Twitter
  • Facebook
  • Identi.ca
  • del.icio.us

Related posts:

  1. Kernel compiling the old-fashioned way
  2. Kernel compiling on PS3
  3. How long does it take to compile a netbook kernel on a PC?
  4. How long does it take to compile a kernel on a desktop PC?
  5. Compiling a tailored kernel

,

  1. No comments yet.
(will not be published)

Switch to our mobile site