Compile and run the Ubuntu Lucid kernel on Ubuntu Karmic

Just as a learning experience for myself I decided to see if I could compile and run the Ubuntu Lucid kernel on my Ubuntu Karmic laptop and with a few bumps along the way I’m currently running the Lucid kernel version 2.6.32-21. I have made some configuration changes to fit the need I have for my laptop (Core2 processor, 4GB memory) but also because I run the proprietary nVidia driver. As Ubuntu Lucid has not yet been released the instructions given here could changes in the final version. This article will probably also work for compiling the Lucid kernel on a Lucid machine but I will write up a how to compile a Lucid kernel for Lucid when Lucid has been released and I have upgraded my laptop.

Lets get started building our own custom Ubuntu Lucid kernel for Ubuntu Karmic from scratch.


I’ll be using git to get the latest kernel version. This is my favorite way to get the sources and it is in my opinion the fastest way to make changes later on when you want to update your own kernel to the latest version.
I suggest adding my Launchpad repository to your system, currently there is no Lucid version yet. The repository holds the latest version of git and is usually updated within a day of a new release of git, follow the instructions on the page Git Packages for Ubuntu to add my repository.

I am compiling the i386 version, if you want to compile for amd64 you need replace i386 for amd64 throughout this article.

I choose the name core2 as the flavor name as for my personal use I’ll build a kernel for a Core2 processor. Besides the change of processor type in the configuration I also select support for 64GB as my laptop has 4GB, which is the main reason I started compiling my own kernels. I have some other changes but that’s beyond this article.


Let’s get started by preparing our machine for compiling the Ubuntu Lucid kernel.
Open a terminal.

sudo su -
apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile kernel-wedge
apt-get build-dep linux
apt-get install git-core libncurses5 libncurses5-dev
apt-get install libelf-dev asciidoc binutils-dev

Create a directory where you would like to build your kernel, this directory will hold the kernel source in a sub directory and all the deb files will end up in this folder. I choose /d1/development/kernel/lucid

Getting the source

cd /d1/development/kernel/lucid
git clone git://  source

The source code is installed in the directory source.

We will create a branch in which we will be doing our modifications. That way the master branch will stay in tact which will make future updates a whole lot easier.
To see the latest version:

cd source
cat debian.master/changelog|more

Press q to get back to the prompt.
This results in something like this:

linux (2.6.32-21.31) lucid; urgency=low

Sometimes you will see the first section as UNRELEASED in that case the latest version is the first version after the UNRELEASED section.
In our case the latest version is 2.6.32-21.31.
You could select any version you see in the changelog but for the sake of this article we’ll use the latest version.

The Ubuntu kernel developers tag each version as Ubuntu- and therefor we can checkout the version we want as

git checkout Ubuntu-2.6.32-31.31 -b core2

This will create a branch called core2.

Creating a new config

I’ll be using the method of creating a new flavor, this adds a bit more work but you can always compile the original kernels.

We’ll use the generic flavor as the base for our own flavor being core2.

cp debian.master/config/i386/config.flavour.generic debian.master/config/i386/config.flavour.core2
fakeroot debian/rules clean
debian/rules updateconfigs

To make changes to the configuration file we need to edit the configuration file. The kernel developers have created a script to edit kernel configurations which has to be called through the debian/rules makefile, unfortunately you will have to go through all the flavors for this script to work properly.

debian/rules editconfigs

The script will show you which configuration is next to be edited. You should not make changes to any of the configurations until you see the core2 configuration

 * Run menuconfig on i386/config.flavour.core2... Press a key.

Make your changes, save the configuration and then keep going until the script ends. You could save the other configurations but you don’t have to. I will write up what changes I made for my configuration in a separate article to be published soon.

When you’re done, make a backup of the config flavor file.

cp debian.master/config/i386/config.flavour.core2 ../. 

Now we need to clean up the git tree in order to get ready for compilation.

git reset --hard
git clean -xdf

Getting ready for compilation

Because we are going to be creating a new flavor based on a existing flavor (generic in my case) we need to create some extra files. During compilation the process checks the previous release for some settings, as we’re creating a local flavor it doesn’t exist in the source, so we’re creating it. The previous release in this case is 2.6.32-20.30

ls debian.master/abi
cp debian.master/abi/2.6.32-20.30/i386/generic debian.master/abi/2.6.32-20.30/i386/core2
cp debian.master/abi/2.6.32-20.30/i386/generic.modules debian.master/abi/2.6.32-20.30/i386/core2.modules

Copy our flavored configuration file back.

cp ../config.flavour.core2 debian.master/config/i386/

We need to edit some files:

File: debian.master/etc/getabis

Search for the line:

getall i386 generic generic-pae 386

Change it in:

 getall i386 generic generic-pae 386 core2

File: debian.master/rules.d/

Search for the line:

flavours        = generic generic-pae 386

Change it in:

flavours        = generic generic-pae 386 core2

We need to make the compilation process aware of our own flavor we want to compile.

cp debian.master/control.d/vars.generic debian.master/control.d/vars.core2

You can edit the file and make it your own.

arch="i386 amd64"
target="Geared toward Core2 desktop systems."
bootloader="grub-pc | grub | lilo (>= 19.1)"
provides="kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-modules-1.9"

We need to commit our changes in the git repository.

git add .
git commit -a -m "Core2 modifications"

The text after -m is the message you add to your commit.


It’s finally time for compiling but before we can start the compilation process there is one more step to do. I didn’t put this in the Preparations section as you need to the following step whether you make changes to the configuration or not

fakeroot debian/rules clean

All the packages will be created in the directory /d1/development/kernel/lucid
Create independent packages:

skipabi=true skipmodule=true fakeroot debian/rules binary-indep

The above statement will create the following deb files:


Create the tools packages:

skipabi=true skipmodule=true fakeroot debian/rules binary-perarch

The above statement will create the following deb files:


Create the flavour depended files:

skipabi=true skipmodule=true fakeroot debian/rules binary-core2

The above statement will create the following deb files:



After the compilation is finished we’ll have the above packages in the parent directory.

To install the files

cd ..
sudo dpkg -i linux-headers-2.6.32-21-core2_2.6.32-21.31_i386.deb linux-headers-2.6.32-21_2.6.32-21.31_all.deb linux-image-2.6.32-21-core2_2.6.32-21.31_i386.deb

Check your bootloader if the newly installed kernel is the default one, for grub check the file /boot/grub/menu.lst or if you run grub2 check /boot/grub/grub.cfg

Reboot and enjoy your newly installed kernel.

This article is filed under the category Ubuntu and has the following tags associated with it: , , .

For more of the same articles see the page Compile a kernel for Ubuntu overview
  • Blazewardog

    I followed your guide here on Lucid and everything seemed to compile fine, however once I rebooted with the new kernel, my nvidia drivers would not load at all. Any clue how I can fix this?

    • By default the opensource nVidia driver Nouveau is enabled in Lucid which can cause problems.
      I Just finished an article on tips for configuring the kernel, explaining this problem besides other tips and I decided to publish it earlier as planned to help out, see the article here:

      • Blazewardog

        Thanks for the info about Nouveau needing to be disabled. After recompiling my new kernel works perfectly. Although this makes me wonder, why do you need to compile it without Nouveau, does it have the same driver name as the binary one? Or did they just do it to mess with Nvidia?

        • The problem is with the Nouveau driver, why Ubuntu made it default has to do with the fact it’s Open Source and not closed like the official nVidia driver.
          Another way to disable the driver, without recompiling, is adding it to the module blacklist.
          Edit the file /etc/modprobe.d/blacklist.conf and add the line
          blacklist nouveau

  • henris

    on first compilation i get error( make: *** [install-tools] Error 1) all tools seem to be updated im on karmic

    • henris

      got solution nice tut thank You.

  • srinath

    i compiled as per steps…..but
    —“cp debian.master/abi/2.6.32-20.30/i386/generic debian.master/abi/2.6.32-20.30/i386/core2
    —-cp debian.master/abi/2.6.32-20.30/i386/generic.modules debian.master/abi/2.6.32-20.30/i386/core2.modules”
    said —could not stat ;error not file or directory
    so i skipped too next steps run till end..
    At last latest kernel is not showing in grub
    plz help