On this page is described an easy way to debug kernel issues, by using "git-bisect". The idea of this tool is to track down a particular issue (or regression) by selecting the faulty revision.

Use cases

Needed tools

For these regression tests, you will need the following packages (to install with your favorite package manager) :

 git-core gitk kernel-package fakeroot

Getting the Linux git source

In this step, we will get a local copy of the whole Linux kernel source code by using Linux's distributed version control system : git.

Move to your source directory

$ cd ~/src

Clone Linus's version (HEAD)

This will download about 170 MiB and thus need some time. Go take yourself a coffee !

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Separate the wheat from the chaff

In that step, we will mark the versions good or bad.

Start the git-bisect process

$ git bisect start

Mark the ''good'' version

For example

$ git bisect good v2.6.25-rc6 

Mark the ''bad'' version

For example

$ git bisect bad v2.6.25-rc7 

At this point, this command should answer you something like that :

Bisecting: 182 revisions left to test after this
[2c7871982cf27caaddbaeb7e2121ce1374b520ff] Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6.25

The interesting part is the number (in our case, 182) which is the number of kernel revisions that lay between your good and your bad.

Build your kernel

In this step, we will configure the future kernel according to the actual configuration and then compile the new kernel.

Copy a valid configuration

For example

$ cp /boot/config-$(uname -r) .config

Configure the kernel

$ make oldconfig

Simply press Enter at each question. (Pro tip: yes "" | make oldconfig)

Build the kernel

This will take a lot of time and computation power too. Get yourself a pause and get your laptop off your legs.

$ fakeroot make deb-pkg

Install the newly created kernel

(According to the name lastly pointed by latest command.

# dpkg -i ../linux-2.6.25-rc6_2.6.25-rc6-2_amd64.deb

Update the initramfs

The version is probably the good one (new version of it)

# update-initramfs -c -k 2.6.25-rc6

Update the boot loader

This is for all versions of Grub. Anyone for LILO ?

# update-grub

Reboot under newly built kernel

# reboot

Test your issue under this kernel