Sunday, April 12, 2009

Compiling kernel on debian or ubuntu

On a Ubuntu 9.04 Jaunty Jackalope, 2.6.28-11-generic #41-Ubuntu

Install necessary tools and get the latest kernel
apt-get install kernel-package libncurses5-dev fakeroot
wget ftp://ftp.sunet.se/pub/Linux/kernel.org/linux/kernel/v2.6/linux-2.6.29.1.tar.bz2

Unpack and change to the source dir
tar xvf linux-2.6.29.1.tar.bz2
cd linux-2.6.29.1

Make sure we clean out old config files and debris if we've compiled from this source before
make clean && make mrproper

Copy the running config,check with uname -r
cp /boot/config-2.6.28-11-generic ./.config

Run menuconfig and pick up the config file, make changes and exit
make menuconfig

If you're on multiple cores/cpus set CONCURRENCY_LEVEL (same as -j for make) to number of cpus/cores.

export CONCURRENCY_LEVEL=2

(It tells make to run multiple jobs in parallel)
Clean then compile
make-kpkg clean
time fakeroot make-kpkg --initrd kernel_image kernel_headers


Afterwards you may have to recompile stuff like graphics drivers (modules) for your new kernel.
With nVidia I just save my current xorg.conf then run the nvidia installer, copy back my xorg.conf and restart X.

NB: You can check module versions (and license) with modinfo