Todd Smith Org

December 31, 2009

Howto Compile an upstream Kernel the Debian / Ubuntu way

Filed under: Server Technology,Unix Administration,Web Hosting — admin @ 12:30 pm

Compile vanilla kernel on debian / ubuntu

I realize that there is more than one way to do this, but this is the way that I have most recently done it, and it works providing you with packages that you can redistribute to your other Debian / Ubuntu machines or friends.

Grab the dependencies you’ll need to build the kernel

apt-get install fakeroot kernel-wedge build-essential makedumpfile \
        linux ncurses-dev git-core linux linux-source ncurses-dev kernel-package

Grab the kernel that you want

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.2.tar.gz
tar zxf linux-2.6.32.2.tar.gz
cd /usr/src/linux-2.6.32.2

Configure the kernel, I use the config from the stock Ubuntu server kernel, then run “make oldconfig” (hold down enter until all the questions are answered and it gives you back a prompt). Then, run “make menuconfig” and add or remove whatever feature has caused you to want to build your own kernel. Save the config.

cp /boot/config-2.6.31-16-server /usr/src/linux-2.6.32.2/.config
make oldconfig
make menuconfig

Now, we’re ready to compile, set the concurrency level to however many processors (including hyperthreads) you have plus 1 or 2. I’m building on a Core i7 860, so I use 9. (Quad core, which hyperthreading, plus) 1 = 9.

Pick a version number for your kernel. It could be anything you want a-z, A-Z, 0-9, +, or . (no underscores “_”). Thi s will go after append-to-version= below

export CONCURRENCY_LEVEL=9
time fakeroot make-kpkg --append-to-version=.31338 kernel_image --initrd binary

This took about 30 minutes on my system, and leaves me with the following files:

real    30m27.995s
user    79m17.300s
sys     10m38.560s
root@replay02:/usr/src/linux-2.6.32.2# ls /usr/src/*31338*
/usr/src/linux-doc-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_all.deb
/usr/src/linux-headers-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_amd64.deb
/usr/src/linux-image-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_amd64.deb
/usr/src/linux-manual-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_all.deb
/usr/src/linux-source-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_all.deb
root@replay02:/usr/src/linux-2.6.32.2#

Now it’s as simple as installing!

dpkg -i /usr/src/linux-headers-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_amd64.deb
dpkg -i /usr/src/linux-image-2.6.32.2.31338_2.6.32.2.31338-10.00.Custom_amd64.deb

Grub2 should automatically have updated and found the new kernel!

I hope this worked out for you.

6 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress