Sunday, April 20, 2008

Ubuntu: Compiling a custom kernel

From: http://www.quietearth.us/articles/2006/09/15/Ubuntu-Compiling-a-custom-kernel

Ubuntu: Compiling a custom kernel
Posted on Friday, September 15th, 2006 22:53:55 GMT by: quietearth
Posted under: ubuntu kernel
Here's a very dirty how to to build a custom kernel for ubuntu. This does not cover propietary drivers such as nvidia or ati. If you are using any propietary video drivers, you will need to modify your xorg.conf, otherwise X will not work when you boot into the new kernel. More detailed instructions are available at the link on the bottom of this post.

# apt-get install ncurses-dev kernel-package linux-source build-essential
# cd /usr/src
# bzip2 -dc linux-source-2.6.15.tar.bz2 |tar xf -
# cd /usr/src/linux-2.6.15


Now lets get our running kernel version and copy over the appropriate config file.
# uname -r
# cp /boot/config-2.6.15-26-386 .config


Now let's configure it, run the following and then set and save your options.
# make menuconfig

Now lets use make-kpkg to compile the kernel and it will produce an installable .deb for us:
# make-kpkg clean
# make-kpkg --initrd --append-to-version=custom1 kernel_image kernel_headers


One problem I ran into while compiling the kernel source was errors in the prism54 wireless driver code. I had to completely remove support to get the kernel to compile.

Now after this is done compiling we can look in /usr/src and we have the following packages:
kernel-headers-2.6.15.7-ubuntu1custom1_10.00.Custom_i386.deb
kernel-image-2.6.15.7-ubuntu1custom1_10.00.Custom_i386.deb


And we can install with:
# dpkg -i kernel-image-2.6.15.7-ubuntu1custom1_10.00.Custom_i386.deb

After installation, your custom kernel will be at the bottom of the grub's list, so it will not be automatically booted. You will either need to move it to the top of the list in /boot/grub/menu.lst or manually stop autoboot in grub and specify booting your new custom kernel.

To remove the kernel, you will have to boot into another kernel otherwise you might destroy your system.
# dpkg -r kernel-image-2.6.15.7-ubuntu1custom1

A more detailed article is available at http://doc.gwos.org/index.php/Kernel_Compilation_Dapper .

Tested under dapper.

No comments:

Post a Comment