www.question-defense.com | Engage: Visit :: Login :: Register

I decided to make a post on recompiling your Ubuntu kernel after after taking a look at the instructions on the Ubuntu wiki. Although the instructions were correct it was a big jumbled mess and almost impossible to figure out what was what from the instructions. This post will cover recompiling the kernel that comes with Ubuntu. The reasons for doing this are to keep the current Ubuntu patches and configs and simply add some stuff of your own. This would be useful for adding a patch of some sort or adding support in the kernel .config for a piece of hardware or software which may not be enabled by default.

For this article I will be using Ubuntu 10.10. these instructions should also work for 9.10 and 10.04 but earlier versions had a slightly different process.

Ok so lets get started:

NOTE: I do every thing as root but I will add sudo to the commands for the people that are not comfortable working as root.

1. Install the required packages

sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev

2. Next issue the following command

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

3. Next e need to create a working directory and download the Ubuntu image which correspond’s with our running kernel.

mkdir ~/source
cd ~/source
apt-get source linux-image-$(uname -r)
cd linux-2.6.35

4. Now, since we are just rebuilding the current kernel we can use the current .config file as a starting point.

cp -vi /boot/config-`uname -r` .config

5. At this point if we have any patch’s we can add those. Generally a patch come in the form of a .patch file and needs to be applied in the top level directory of the source which in this case would be ~/source/linux-2.6.35

patch -p1 < example.patch

Do this for all patch’s you may need to apply.

6. Next we will open the ncurses editor for the .config file. This is where all the support is defined for the kernel.

make menuconfig

I’m going to assume you know what kernel options you need. This is also a good chance to remove support for anything you do not need. Smaller kernel with less bloat can greatly improve performance.

7. Save the menu file and exit the interface.

8. At this point you should be in the ~/source/linux-2.6.35 directory again

9. A little trick you can do is to set the CONCURRENCY_LEVEL variable to speed up the compile of the kernel. The number should be the number of processors you have plus one. So in my case I have a dual core processor so I will add one which would be three.

export CONCURRENCY_LEVEL=3

10. Lets build it! You need to add a custom string to the end to mark your new kernel. In this case I added “-QD” to the end but you can add what ever you want

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-QD kernel-image kernel-headers

11. At this point you should go grab some food because the kernel compile can take a while

12. Once the kernel is built it will be one directory up in the ~/source file we were originally working in.

cd ~/source
sudo dpkg -i linux-image-2.6.35.(This part will be whatever name you gave it).deb
sudo dpkg -i linux-headers-2.6.35.(This part will be whatever name you gave it).deb

There will only be these 2 debs so use tab complete to get the correct names. The dpkg commad will do the actual installing of the kernel.

13. Now we need to make a initramfs.

sudo update-initramfs -c -k 2.6.35+QD

You will need to add your kernel version + the custom string you added on the end.

14. Now lets update grub

sudo update-grub

15. Reboot and you should be rocking with your new kernel!


List Price: $49.99 USD
New From: $25.55 In Stock
Used from: $19.70 In Stock


List Price: $24.99 USD
New From: $14.15 In Stock
Used from: $7.98 In Stock

DeliciousStumbleUponDiggTwitterFacebookRedditLinkedInEmail

Related posts:

  1. Compile Litespeed PHP To Include GD FreeType Support, GD FreeType Linkage, and GD JPG Support I was recently installing KBPublisher on a web server running...
  2. Rooting the HTC Evo 4g – Part 7 (Installing A Custom Kernel) **This is entering the realm of experimental stuff** **Make sure...
  3. How to Install Skype in Ubuntu 10.04 Lucid Lynx I just got around to downloading The new LTS release...
  4. Dell Support History: Direct Link to Dell Support History & Status Web Page I recently needed to look up number support tickets I...
  5. How to Switch Between Different Versions of GCC and G++ in Backtrack 4 Final (Or Any Version Of Ubuntu) I had a Backtrack user on IRC today asking about...
Tags: , , , , , , , , , ,
31 Responses to “How to Recompile Your Ubuntu 10.10 Kernel for Patching or to add Support for a Specific Device”
  1. storm says:

    Great write-up AND it worked for me.

    Could you explain though how to re-compile and install the kernel WITHOUT making clean on subsequent builds?

    I will be making changes to a single kernel file (not part of a module) and need to just recompile, install, reboot and test until it works for me. Making clean as part of the build process takes way to long on the machine I’m using.

    [Reply]

    purehate Reply:

    Just do not issue the make clean command

    [Reply]

  2. Divaniti says:

    i have BCM4312 wireless adapter and it’s not capable with packet injection in aircrack-ng i did a lot of search and they recommended me to patch my wireless driver or update my kernel
    i’m using ubuntu 10.10
    would these mentioned steps help?

    [Reply]

    purehate Reply:

    Yes this method is for adding kernel patches

    [Reply]

  3. Jean-Paul says:

    I just recompile my Ubuntu 10.0 system. The directions were right on. Just boot up and everything works fine. No more freezes with some apps.

    Thanks

    [Reply]

    purehate Reply:

    Good to hear, thanks for leaving feedback

    [Reply]

  4. None says:

    At what point in these directions do I modify the kernel code?

    [Reply]

  5. LAMA says:

    That is a good step-by-step guide, purehate, I’ve been looking for something like that.
    The only problem I have is that linux-image-$(uname -r) in steps 2 and 3 gets me only the newest kernel (there’s a comment: Picking ‘linux’ as source package instead of ‘linux-image…).
    Do you think you could advise?

    [Reply]

  6.  
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*