Friday, 29 April 2011

How to recompile your Ubuntu 11.04 Kernel

This quick how to guide will show you how to recompile your Ubuntu 11.04 (2.6.38.2) Kernel using the terminal.

1. Install these packages

sudo apt-get install kernel-wedge kernel-package libncurses5-dev

2. Run this command

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)

3. Create your source directory

mkdir ~/src

cd ~/src

4. Download the Kernel source

apt-get source linux-image-$(uname -r)

5. Configure your Kernel

cd linux-2.6.38

make menuconfig

6. Speed up the build

export CONCURRENCY_LEVEL=3

General rule, concurrency level = number of processor cores + 1


7. Clean up temp files from a previous compile attempt (skip if necessary)

make-kpkg clean

8. Compile your Kernel

time fakeroot make-kpkg --initrd --append-to-version=-tweak kernel-image kernel-headers

You can change -tweak to anything you wish


9. Install your Kernel

cd ~/src

sudo dpkg -i linux-image-2.6.38.2-tweak_2.6.38.2-tweak-10.00.Custom_amd64.deb

sudo dpkg -i linux-headers-2.6.38.2-tweak_2.6.38.2-tweak-10.00.Custom_amd64.deb

10. Reboot



7 comments:

  1. Great post, i used it but found the location to select my kind of processor, is this normal??

    Thank you!

    ReplyDelete
  2. Sorry but I am having trouble understanding your question.

    ReplyDelete
  3. Im getting a "E: You must put some 'source' URIs in your sources.list" error. Do you know what I should add to the sources.list file?

    ReplyDelete
  4. Nevermind, I found them :-) Thanks for the helpful post BTW.

    deb-src http://us.archive.ubuntu.com/ubuntu/ natty-security main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ natty-updates main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ natty-proposed main restricted universe multiverse

    ReplyDelete
  5. Awesome. Most awesome my friend... that was fun for me. I'm a hobbyist and I enjoyed the rather LOOOOONG list of options in step five... couldn't have done it without you bubba!

    ReplyDelete
  6. I just had problem of Kernel PANIC:

    Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

    Which I got when I tried to boot into the 'tweak' kernel.
    To fix this I had to update initramfs and grub2 using the following commands:

    update-initramfs -u -k 2.6.32.46+drm33.20-tweak

    (The above kernel version is at /lib/modules
    cat /lib/modules would show that)

    update-grub2

    This solved my problem and I have a recompiled kernel :)

    ReplyDelete
  7. Going by the kernel version Arnold, it seems you are using 10.04 and not 11.04 which this guide is aimed at.

    With 10.04 you have to run update-initramfs as you described followed by update-grub.

    11.04 does these steps automatically.

    ReplyDelete