How to compile a custom kernel for Ubuntu Intrepid using git

Previously I wrote an article on how to compile a custom kernel for Ubuntu Intrepid, it used the apt-get method for getting the kernel source. If you prefer to use git to get the latest kernel source you can use this post. Most of this post is a copy of the previous post but to make it easier to follow the instructions I decided to write up everything in this post as well.

Jan 8, 2009: Added git add to the “commit the changes” section.
Dec 11th: Added installation of needed packages.
Nov 27th: Added command to change to intrepid directory.
Oct 31st: I changed some steps in the section Getting ready for compilation to be prepare ourselves for compiling new releases of the kernel.

I’ll be doing everything as root.
First we need to install some applications so we can do the compilation:

apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile
apt-get build-dep linux
apt-get install git-core libncurses5 libncurses5-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/packaging/kernel as I package other software as well. All the commands I type will be done from this directory.

Getting the source

There are a couple of ways to get the kernel source from Ubuntu, using git which this article is using or by using apt-get. If you prefer to use apt-get follow my other article I have written.
To get the source using git

git clone git:// intrepid

The source code is installed in the directory intrepid.

We create a branch with a copy of the kernel version we want to work on. To determine which the latest official release is:

cd intrepid
git tag | grep Ubuntu*

This results in something like this:

git checkout Ubuntu-2.6.27-7.14 -b 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. Now for the fun stuff, editing the config so it fits my needs. I won’t go into detail which settings I changed, if somebody is interested I certainly can give that information. I use the current running config as my base.

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

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

mv .config ../config.core2

Now we need to clean up the git tree

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. My previous version is 2.6.27-7.13.

cp debian/abi/2.6.27-7.13/i386/generic debian/abi/2.6.27-7.13/i386/core2
cp debian/abi/2.6.27-7.13/i386/generic.modules debian/abi/2.6.27-7.13/i386/core2.modules
cp ../config.core2 debian/config/i386/

We also need to edit some files

  • debian/scripts/misc/getabis
  • debian/rules.d/
  • debian/control.stub
  • debian/control

In the next few parts I’ll explain what you need to change

File: debian/scripts/misc/getabis

Search for the line:

getall i386 generic server

Change it in:

getall i386 generic server core2

File: debian/rules.d/

Search for the line:

flavours        = generic server

Change it in:

flavours        = generic server core2

Files: debian/control.stub and debian/control

For both files we need to copy three sections:

  • Package: linux-image-2.6.27-7-generic
  • Package: linux-headers-2.6.27-7-generic
  • Package: linux-image-debug-2.6.27-7-generic

A section is defined from the line Package to the next line starting with Package.
In the copied sections we need to replace “generic” with “core2” on all the lines that start with Package.

Now 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.

CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-core2

Because I have a Dual Core I want to utilize both processors by setting the CONCURRENCY_LEVEL. Set this to the amount of processors you have, if you have only one, just skip it completely. No matter grab yourself some coffee while we’re compiling.


After the compilation is finished we’ll have two deb files in the parent directory. To install the files

dpkg -i linux-image-2.6.27-7-core2_2.6.27-7.14_i386.deb
dpkg -i linux-headers-2.6.27-7-core2_2.6.27-7.14_i386.deb

Check your bootloader if the newly installed kernel is the default one, for grub edit the file /boot/grub/menu.lst

Reboot and enjoy your newly installed kernel.

This article is filed under the categories Ubuntu » Compile a kernel and has the following tags associated with it: , , , , .
  • Shawn Faure

    I have not been able to find the linux-kernel-devel package. You might want to add a comment as to how you resolve that.

  • Peter

    Thanks for reporting this, this is another thing that has changed in Intrepid. I’ll change the article as well but what you need to do is
    sudo apt-get build-dep linux

  • when installing I get the following message:

    # sudo dpkg -i linux-headers-2.6.27-7-core2_2.6.27-7.15_amd64.deb
    Selecting previously deselected package linux-headers-2.6.27-7-core2.
    (Reading database … 162147 files and directories currently installed.)
    Unpacking linux-headers-2.6.27-7-core2 (from linux-headers-2.6.27-7-core2_2.6.27-7.15_amd64.deb) …
    dpkg: dependency problems prevent configuration of linux-headers-2.6.27-7-core2:
    linux-headers-2.6.27-7-core2 depends on linux-headers-2.6.27-7; however:
    Package linux-headers-2.6.27-7 is not installed.
    dpkg: error processing linux-headers-2.6.27-7-core2 (–install):
    dependency problems – leaving unconfigured
    Errors were encountered while processing:

    I searched in synaptic for linux-headers-2.6.27-7 but couldn’t find it…not sure what I’m doing wrong. My current kernel version is 2.6.24. Also, the linux-image deb installation went fine. I’m going to go through the steps again and make sure I didn’t forget anything.

  • I found the headers at launchpad, after which I could install just fine. The only snag I ran into was that I needed some firmware that was included under /lib/firmware/my-old-kernel-generic/, but wasn’t under /lib/2.6.27-7-core2. I copied it over and now life is good.

    Could you explain how the firmware gets to the above locations and why it isn’t by default included in the git tree, when it is included in the generic kernel binaries?

    Thanks for the how-to. I’ve tried installed kernels before but this is the first time it went smoothly and I have a fully-operational system.

  • Peter

    I’m glad it worked out at the end.

    In your case I do believe it’s better to do this for compilation:
    CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-debs

    This will compile all kernels for your architecture, including your missing linux-headers.

    I’m not sure why you had to copy your firmware over, my guess would be that you upgraded from kernel 2.6.24 to 2.6.27.
    What’s the output of dpkg -S /lib/firmware/my-old-kernel-generic/your-missing-firmware-file

  • Peter

    Instead of
    CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-debs
    after you compiled your kernel you should run
    CONCURRENCY_LEVEL=2 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-indep
    This will create the linux-headers deb you are missing.

  • zeus

    Thanks Peter for your guide. Followed your steps and managed to compile my first custom kernel.

    However i have a question for you.
    Now that my custom kernel is fully functioning since i applied couple of patches for my wifi card if a new kernel is out in few days time what is the best way to carry out such upgrade? Do i have to repeat the initial steps? Surely it should be a quicker way of doing this…

    Thanks in advance

  • Peter

    RE: zeus
    Congratulations on compiling your very first custom kernel.

    No luckily you don’t have to go through the whole process.
    I wrote a follow up article for these situations:

    In your case it could get a bit tricky as it sounds like you changed the kernel source and not just the debian files. If you read the mentioned article you’ll see you’ll have to merge the new release of the kernel into your branch. Sometimes this is tricky.

    If the patches you applied for your wifi card are just that, patch files, I suggest you apply these patches after the final commit, just before the compilation of the kernel. It will make the the merging some what easier.

    Keep us posted how it works out for you when you update the kernel to a newer release.

  • Nice guide – thanks very much for sharing. For ages I had an older (8.04 i think) version of ubuntu running on some old board with a silicon images 3114 sata raid controller. I was just using it for the extra ports mind you. Anyway, the board died recently so I’ve been building a new system around an atom mini-itx board.

    Unfortunately I never even managed to get ubuntu to install with the SiI controller in there. By removing it I was able to install but still stuck without the card working (the machine would lock up at some random point after starting to boot the kernel). I finally recalled some special instructions ( to enable SiI support, but quickly realised ubuntu’s moved on a bit since then.

    With the aid of your guide I’m now waiting for my kernel to compile – cheers!

    One point you ought to update: After performing “git clone git:// intrepid” you need to move into the ‘intrepid’ directory or the rest of the commands won’t work.

  • Hrm… got to the end(?) of the compile to find the following:

    install -d /tmp/ubuntu-intrepid/debian/abi/2.6.27-9.19/i386
    find /tmp/ubuntu-intrepid/debian/build/build-core2/ -name \*.ko | \
    sed -e ‘s/.*\/\([^\/]*\)\.ko/\1/’ | sort > /tmp/ubuntu-intrepid/debian/abi/2.6.27-9.19/i386/core2.modules
    II: Checking modules for core2…
    reading new modules…read 2184 modules.
    reading old modules…
    MISS: 6pack

    MISS: zd1211rw
    read 2286 modules : new(0) missing(102)
    WW: Explicitly asked to ignore failures (probably not good)
    II: No new modules (hope you’re happy, slacker)
    II: Done
    /bin/bash: dh_testdir: command not found
    make: *** [install-core2] Error 127

    …any ideas? This thread: suggests I might need debhelper?

  • Yep, debhelper fixed it ๐Ÿ™‚

  • One more error though:

    # Remove files which are generated at installation by postinst.
    rm -f /tmp/ubuntu-intrepid/debian/linux-image-2.6.27-9-core2/lib/modules/2.6.27-9-core2/modules.*
    dh_installchangelogs -plinux-image-2.6.27-9-core2
    dh_installdocs -plinux-image-2.6.27-9-core2
    dh_compress -plinux-image-2.6.27-9-core2
    dh_fixperms -plinux-image-2.6.27-9-core2
    dh_installdeb -plinux-image-2.6.27-9-core2
    dh_gencontrol -plinux-image-2.6.27-9-core2
    dpkg-gencontrol: warning: can’t parse dependency ndiswrapper-m$
    dpkg-gencontrol: warning: can’t parse dependency ndiswrapper-m$
    dpkg-gencontrol: error: error occurred while parsing linux-image, linux-image-2.6, fuse-module, kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-m$
    dh_gencontrol: command returned error code 65280
    make: *** [binary-core2] Error 1

  • Peter

    Thanks for the pointer of the missing cd.

    On your last error, it looks like a problem in the debian control file
    debian/control and debian/control.stub
    Check the section Package: linux-image-2.6.27-9-core2 and then the line starting with Provides.
    It should read:
    Provides: linux-image, linux-image-2.6, fuse-module, kvm-api-4, redhat-cluster-modules, ivtv-modules, ndiswrapper-modules-1.9

  • Thanks Peter – you were right. I was copying / pasting over putty and didn’t spot that some lines where wider than my screen. After fixing that and installing the linux-headers- package I was able to install it all and finally have my fileserver working once again.

    Thanks so much!

  • Auders

    Hi, thanks for the guide, it really helped me out.

    This is perhaps a little off topic, but why is there both debian/control and debian/control.stub?
    As far as I could see they are exactly the same…

    • The stub file is used a an original backup for the control file.
      During the building process the control file is modified and when you run the clean action the stub is copied back as control file.

  • michael

    Before you do the git commit you need to ‘git add’ the new files that are created, otherwise they won’t be committed.

    • Thanks Michael for that catch.
      For some reason I remember the -a switch to also add new file, but I might be wrong. I changed the article

  • Zoltan

    Peter I always run into this error:
    I tried it a couple of times, I even redid it from the beginning.

    install -m644 -D /root/src/intrepid/debian/build/build-core2/arch/x86_64/boot/bzImage \
    install -m644 /root/src/intrepid/debian/build/build-core2/.config \
    install -m644 /root/src/intrepid/debian/abi/2.6.27-9.19/amd64/core2 \
    install -m644 /root/src/intrepid/debian/build/build-core2/ \
    makedumpfile -g /root/src/intrepid/debian/linux-image-2.6.27-9-core2/boot/vmcoreinfo-2.6.27-9-core2 \
    -x /root/src/intrepid/debian/build/build-core2/vmlinux
    get_debug_info: Can’t create a handle for a new debug session.

    makedumpfile Failed.
    make: *** [install-core2] Error 1

    • My guess is you disabled the Kernel Debugging in the configuration.
      You can turn it back on or edit debian/rules.d/ and comment out the lines with the command makedumpfile.

      • mikez

        I am using the Ubuntu-Jaunty (9.04-beta) release (which may be different than 8.10) – –
        You can skip the makedumpfile command by adding:
        to the build command line given in this article.

  • Zoltan

    Thanks it compiled just fine. I have an other question. After compile my wireless card is not working. I did not use ndiswrapper and I know how to fix my problem with that one. But there is that comfortable feature in ubuntu called hardware drivers and it can get drivers in my case for the screen and the wireless with the packaged kernel. The nvidia driver works fine with the new compile, but with the wireless is not and it doesn’t even shows in the hardware drivers applet. Do you know what can be the reason?

    • Which wireless card do you have, or better which chipset?
      It could mean the wireless driver needs to be compiled with the new kernel.
      I use the official nVidia driver and with most kernel upgrades I need to reinstall (which is recompiling) the driver.
      My wireless card, Intel 4965, is supported in the kernel. Check the wireless options in the kernel configuration, yours might be in there as well.

  • Robsn

    first of all thanks for this guide. this is my first time compiling a kernel.
    i went through the guide step by step very careful but compiling doesn’t work, this is what i get:

    sudo CONCURRENCY_LEVEL=4 NOEXTRAS=1 skipabi=true skipmodule=true fakeroot debian/rules binary-core2
    make: *** No rule to make target `binary-core2′. Stop.

    the debian/rules directory exists.
    I have a Q6600, therefore i set the CONCURRENCY_LEVEL=4. my current kernel is 2.6.27-9-generic. pls help me on this issue. thanks!

    • Double check the files you edited for spelling errors:
      * debian/scripts/misc/getabis
      * debian/rules.d/
      * debian/control.stub
      * debian/control

      A typo is the problem 9 out 10 times.

      • Addiel

        Im having the same issue and i’ve checked 3 times for spelling… Does it makes a difference that i’m using git for kernel 2.6.28?

        • Are you compiling for Intrepid?
          What source did you use for the 2.6.28 kernel?

  • Luis

    Hi, I am from Bogota, Colombia.
    Thanks for your article. I finally could recompile my first kernel. I had the same problem as Robsn:
    make: *** No rule to make target `binary-core2โ€ฒ. Stop
    This was only because I installed the 64 bits iso cd, which says “amd64” arquitecture for both Intel and Amd machines. When I execute the next 3 lines:

    cp debian/abi/2.6.27-7.13/i386/generic debian/abi/2.6.27-7.13/i386/core2
    cp debian/abi/2.6.27-7.13/i386/generic.modules debian/abi/2.6.27-7.13/i386/core2.modules
    cp ../config.core2 debian/config/i386/

    also to the “amd64” directories (not only the i386 ones), the compilation succeded.
    Hope this information is useful, thanks a lot.

  • Alex

    Hello. I followed the instructions posted her very carefully, however I run into some trouble. Please, help! Here is the error that I got. Thanks.

    II: New modules (you’ve been busy, wipe the poop off your nose)
    II: Done
    dh_clean -k -plinux-image-2.6.27-11-core2
    dh_clean -k -plinux-headers-2.6.27-11-core2
    dh_clean -k -plinux-image-debug-2.6.27-11-core2
    # The main image
    install -m644 -D /home/nexus/intrepid/debian/build/build-core2/arch/i386/boot/bzImage \
    install -m644 /home/nexus/intrepid/debian/build/build-core2/.config \
    install -m644 /home/nexus/intrepid/debian/abi/2.6.27-11.24/i386/core2 \
    install -m644 /home/nexus/intrepid/debian/build/build-core2/ \
    makedumpfile -g /home/nexus/intrepid/debian/linux-image-2.6.27-11-core2/boot/vmcoreinfo-2.6.27-11-core2 \
    -x /home/nexus/intrepid/debian/build/build-core2/vmlinux
    /bin/bash: makedumpfile: command not found
    make: *** [install-core2] Error 127

    • Alex

      Great! I think I found my answer in one of your previous posts… I am running a new kernel now thanks to you! Many thanks, Peter!

  • Tim

    1st off.. Thanks for this guide. It’s worked several times for me. Thank you!

    The issue at hand: If I understand this right…when I do :~/mykernel/intrepid$ git tag | grep Ubuntu* it returns with a list of available kernel versions? right? Say for example, I want to select 2.6.27-9.19. Why is it that when I do :~/mykernel/intrepid$ git checkout Ubuntu-2.6.27-9.19 -b core2 and I check the debian/abi directory, the version I chose is not in the list, but rather, for example, today is… 2.6.27-7.16 and yesterday was something else?

    I’m a bit baffled. I’m not making typos as I’ve tested this numerous times with different kernel versions. Typically, I just edit the commands to use whatever version is in the debian/abi folder and proceed, typically with working results. Thanks again for the help!

    • You are correct on the git tag returning a list of tagged kernel versions.
      The version in the debian/abi directory isn’t the version you want to compile, it’s actually a previous version.
      As to why the previous version is so much I have no answer.

      What I have noticed that sometimes I also see the latest previous version in the abi directory, but that probably has to do with messing around in the original branch. I then just reset the master branch to the latest version (git pull), delete the branch and do the git checkout again.

      It shouldn’t change depending on the day you do the git checkout.

  • Psyllon

    I am getting this error…

    Reading old symbols (4)…read 2282 symbols.
    II: Checking for missing symbols in new ABI…
    Missing module name in is_ignored() at debian/scripts/abi-check line 69.
    make: *** [abi-check-core2] Error 255

    Your help is much appreciated…

    • Did you do create the core2 files in the previous abi directory? It’s the first step in Getting ready for compilation.
      cp debian/abi/xxxxxxx/i386/generic debian/abi/2.6.27-7.13/i386/core2
      cp debian/abi/xxxxxxx/i386/generic.modules debian/abi/2.6.27-7.13/i386/core2.modules

      • Psyllon


        Thank you, for your comment… I think I found the answer that I sought. By the way, this is some great HOWTO.

  • to

    huge applause and thanks for an amazing tutorial from Lithuania! worked like a charm!

    all the best,

  • smeagol

    Hi Peter,

    Thank you for such a great article. I have 4GB of RAM and the default Ubuntu kernel only sees 3.3GB. So I stumbled upon your post and decided to give it a try. Initially, I only changed the memory option to 64GB and recompiled following the instructions in your article. This worked great and even the nVidia module was installed correctly by the installer. I only had to recompile madwifi because the kernel’s ath5k module would do strange things to my machine after 2nd suspend to RAM. Anyways, later I decided to change the processor family to Core2/Xeon (hoping there were some cool kernel optimisations for my Core 2 CPU). So I used the same method, but changed the config to reflect the new choice. The compilation went fine, but upon reboot the nVidia module could no longer be inserted into the kernel. Inspecting the dmesg output, the following was found:

    nvidia: version magic ‘2.6.27-14-core2 SMP mod_unload modversions 586 ‘ should be ‘2.6.27-14-core2 SMP mod_unload modversions CORE2 ‘

    The problem is obviously in the versioning of the modules. I’m just not too sure how to fix it. Any suggestions?

    • Jasmine Hasan

      I’m guessing you probably compiled as root, leaving the sources in /usr/src/linux-2.6.xx
      Then, when you install the linux-image deb, ubuntu (and i think debian too) links the ‘/lib/modules/2.6.xx-xx-xxxx/build’ directory to /usr/src/linux-2.6.xx, even if you have installed linux-headers deb simultaneously, which is very bad news.. Any weirdness, or any changes that happen to your /usr/src/linux-2.6.xx directory, and you will no longer be able to build/update modules that work.. this drove me nuts before, until i found the reason why this was happening, on a debian forum

      1. You should not compile sources as root. If you prefer to build your sources in /usr/src, add your user to the src group, then unpack the sources tarball as your user, and use fakroot for all.. Then once you have the debs built in /usr/src, rename the source directory and then `sudo -i *.deb`, or just delete the source directory altogether, or better yet, build the sources in your home directory
      2. If for some reason you did not do all in #1, and you ended up seeing ‘/lib/modules/2.6.xx-xx-xxxx/build’ symlinked to /usr/src/linux-2.6.xx, delete the symlink, and manually symlink it to your newly installed /usr/src/linux-headers-2.6.xx-xx-xxxxx. This way, when you reboot, and dkms kicks in to build and install your nvidia and ath5k and other dkms based modules, it will use the headers directory and not the “unclean” source directory
      3. Make sure if you had had dkms build your nvidia or ath5k or other modules for that same custom kernel before, to “remove” them from the dkms build tree first, so they can be rebuilt upon reboot, rather than being installed from previously built sources that will most definitely have different modules versioning….

      hope this helps u, or anyone else, give it’s been a while since you posted ur question and you probably figured it out by now ๐Ÿ™‚

  • Pete

    Peter, I got everything to compile/install using your tutorial! Thank you for posting such a great guide.

    I need to modify the TCP protocol in the kernel (class project). I modified a few C (tcp_output.c) files in net/ipv4 and I compiled with no errors. I’m afraid the changes I made aren’t getting compiled for whatever reason.

    I just tried entering “this should not work; ” in the C file, to check if any errors are generated during compile time, and it compiled fine. I think they aren’t being linked.

    Sorry for such a basic question. How do I tell the compiler to include all files?


  • stoner_di

    I want to ask someone tried to incorporate the bootup logo ( mini tux in the top left of the display to load the system).
    Perform all necessary for this:
    – when compiling the kernel, I select this:

    Support for frame buffer devices FB->VESA VGA graphics support FB_VESA

    Select all in the:

    Console display driver support ->

    selct all in the:

    Bootup logo LOGO->

    -in the GRUB, in the file menu.lst fix this row:

    kernel /boot/vmlinuz- root=UUID=d5b52903-5…. video=vesafb vga=0x0323 ro quiet

    -in the file /etc/modprobe.d/blacklist-framebuffer.conf, comment this row:

    #blacklist vesafb

    -in the file /etc/initramfs-tools/modules, add:


    -in the end update initramfs this command:

    update-initramfs -u

    In all my UBUNTU not load boot logo!!!!!!!!

  • Jasmine Hasan

    On Karmic 9.10, using sources from `apt-get source linux-image-$(uname -r)` (2.6.31-10), the structure of the kernel’s source debian sub-directory has changed quite a bit. All the files mentioned in the “Getting ready for compilation” section were moved out from “debian” to “debian.master” sub-directory, so I had to improvise.

    Also, the naming convention of the config files changed.
    For example, substitute:

    Finally, I realized that the two files, ‘control’ and ‘control.stub’, which I edited prior in the “debian.master” directory were somehow not used, and I got an error in the end saying something like linux-image-2.6.31-10blabla was not in control file…. I suspected my changes were reset, so I checked debian.master/control and debian.master/control.stub and my changes were still intact, but then I found clean (unedited) copies in the “debian” directory, dont ask… lol ๐Ÿ™‚ So, I just copied my edited “control” and “control.stub” files from “debian.master/” over to “debian/” and re-ran, and voila! I got me two debs ๐Ÿ™‚

    Thanks for this very useful howto… I was just so used to the “old-fashioned” debian way, and wanted to try the “ubuntu” way for conformance sake… ๐Ÿ˜€


    • Jasmine,

      This article is one of my older posts, I revised an article on how to compile a kernel for Jaunty because the changes you are talking about, debian and debian.master are also made into the Jaunty 9.04 kernel.
      This article explains how to go about with the changes.

  • Thanks for the guide.

    Would you mind adding a few sentences about what NOEXTRAS=1, skipabi=yes and skipmodule=yes do?