Main image
27th January
2009
written by Francisco Sayan

(note, this should work on most debian based systems, etch, lenny,  ubuntu,etc)

Well, thanks to Fedora 10 i recently learned that if I wanted to install the (recently released for linux) driver for my Debian Lenny computer. I would need a better kernel. Unfortunately, Lenny is on a freeze right now, and neither Debian testing nor unstable have a newer kernel on stock other than 2.6.26

I decided to install the 2.6.28 kernel from source, and decided to do it the debian way, since i run debian so it makes sense, and also because word on the street is that the debian way is easier on most distros. It involves making a .deb package from the source code and then installing it, and it works wonders :).

After googling around for a little bit, I found a guide to compile a kernel the debian way (http://www.howtoforge.com/kernel_compilation_debian_etch), but it was a little bit out off date and i had to tweak some things here and there to optimize it for my needs

First of all,

Install these packages

apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 build-essential

this is the directory we will compile our kernel in

cd /usr/src

i went over to http://www.kernel.org/ to download the latest stable kernel, which at the moment is 2.6.28. Find the kernel and get it into /usr/src. I used wget to download it, but you could just download it by clicking on the link and then just moving it into /usr/src if you are unable to use wget.  If you can, just copy the link for the kernel and paste it after wget.

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.2.tar.bz2

then we unpack the downloaded file.

tar xjf linux-2.6.28.2.tar.bz2
ln -s linux-2.6.28.2 linux
cd /usr/src/linux

Now we can configure our new kernel. I liked the idea the guy in the “howtoforge” link above had, to use the configuration file from your previous kernel in your new kernel. This insures that any options or settings that your old kernel had still apply in your new kernel. Of course we can also edit this configuration file to personalize it to our needs

make clean && make mrproper
cp /boot/config-`uname -r` ./.config

this will create a menu to config your kernel

make menuconfig

Go down the list to  “Load an Alternate Configuration File” and choose .config. After you do that you can edit and tweak this file to personalize it better, but unless you dramatically change it, it should work fine with your distribution; unless, you are trying to install a new kernel in a hopelessly out of date system, of course.

Make sure you save your work, or it wont use your settings (i’ve heard of some people do this, how?      i dont know)

We are almost done with the hard part, now its time to build the kernel!

make-kpkg clean
fakeroot make-kpkg –initrd –append-to-version=-custom kernel_image kernel_headers

(note: wordpress is condensing the two minus signs before the initrd and append into one giant one, making it so that if you just copy and paste this code it won’t work, if this happens to you just delete the giant minus sign before initrd and append and type two minus signs, now it should work)

After –append-to-version= you can write any string that helps you identify the kernel, but it must begin with a minus (-) and must not contain whitespace( i just kept custom kernel_image because it fit right, i had made several tweaks to my kernel.)

you’ll find two .deb packages in /usr/src. Now this is a tip for everyone out there who is like me and likes to reinstall their computers a lot: that took some time so far right? especially the building right? you wouldn’t want to go trought that again now would ya? Well the good news is that these .deb packages can be copied and pasted into other Debian based systems and install them there just by double clicking on them, saves you some time huh? i got copies on my FAT32 partition is use to save things i think i may reuse if i reinstall.)

Anyways, run these commands

cd /usr/src
ls -l

now to install the kernel, you can either opt to do this the easy but geeky looking way

dpkg -i linux-image-2.6.28.2-custom_2.6.28.2-custom-10.00.Custom_amd64.deb
dpkg -i linux-headers-2.6.28.2-custom_2.6.28.2-custom-10.00.Custom_amd64.deb

or do it the less cool looking, simple way, just double clicking the .deb packages and installing them with something like gdeb.

now just reboot the pc

grub should automatically add your kernel and make it the default kernel

13 Comments

  1. Ruben
    17/02/2009

    Thnx Francisco! This is great. I agree with your love for Debian.
    Very clear manual. My kernel was corrupted but now he is fine and upgraded from 2.6.26-1 to 2.6.28-2.
    The only thing I was missing with “apt-get install” was “zlib1g-dev”.

  2. 24/02/2009

    This has gotten me excited about trying Debain 5.0 Final on my MacBook. I’m downloading it now.

    I see that you’ve written this for Lenny Testing. My question is, do you suppose that this same guide will work under Lenny Final? Thanks in advance for any feedback.

  3. Francisco Sayan
    Francisco Sayan
    08/03/2009

    Yes, this will work in Lenny final.

  4. Jayesh Badwaik
    28/03/2009

    Does this install kernel headers too?

  5. Francisco Sayan
    Francisco Sayan
    20/04/2009

    yes this will create 2 packages, one the image and the other is the header. The last command on the guide will install the header.

  6. Suat
    28/04/2009

    I love Debian and now running after compiiling and installing with kernel 2.6.28.9 thanks alot.

  7. eoliver
    11/06/2009

    Thanks for taking the time to share this with us.

    Debian is my favourite, but I’m now unable to connect to the internet (so slow that it can’t open a page) since I issued the cmd:

    ifconfig eth0 txqueuelen 1000 (before was 1, default) — please don’t try it.

    that didn’t make any problem with Fedora(on same machine) though.

    So, I’m going to reinstall it (again) and this time will update the kernel

    Why do we love Debian? I am unable to answer this, this system gave me so much hassle……. still it is my favourite system!

  8. gydders
    15/06/2009

    Thanks. I too had been looking for a more up-to-date guide.

  9. Nicolas Buduroi
    21/07/2009

    Doesn’t

    wget bzip2 build-essential

    should be

    apt-get install bzip2 build-essential

    ?

    ;-)

  10. Nicolas Buduroi
    21/07/2009

    OK, I got it, my screen is not wide enough!!!

  11. scot
    01/09/2009

    This failed for me on debian lenny unless you have zlib1g-dev installed, maybe you could add that, just in case others have the same problem i did, that aside thanks for the run through, much appreciated

    Scot

  12. TCPMeta
    21/10/2009

    Thanks for the guide. I compiled and installed 2.6.31.4. While I was at it I changed some settings around like disabling crap that is not needed on a desktop like special laptop support, tokenring, and IPv6 since I still use a IPv4 network.

  13. berni
    12/11/2009

    Hi,
    I have to make changes to kernel files (read_write.c in fs). How can I avoid that the whole kernel is compiled and make only compiles the changed file.
    Any ideas?
    thanks

Leave a Reply