Dashboard > Linux > Building a Custom Linux Kernel
Linux Log In   View a printable version of the current page.
Building a Custom Linux Kernel
Added by Scott Kveton, last edited by Scott Kveton on Jun 08, 2004  (view change)
Labels: 
(None)

The following describes how to build a custom Linux kernel for Debian GNU/Linux.

I'm sure there are better ways to do this but this seems to be the most reliable for me and our environment here. As always, I'm open to comments and suggestions on how to improve this document.

So you've got your machine installed (possibly using my ISO) and now you want to put a better/more customized kernel.

Installing a fresh kernel

First off, install the 'kernel-package' debian package by running 'apt-get install kernel-package'.

Now get the latest/greatest source from www.kernel.org. As of this writing its 2.4.25.

Copy the source into /usr/src (this can be anywhere but this is the most common), tar zxf it there.

We'll take the first case that you have never installed a Debian kernel and that you don't have X installed/working.

Make sure you have the libncurses5 and libncurses5-dev packages installed (apt-get install libncurses5 libncurses5-dev).

cd /usr/src/linux
make menuconfig

Configure your kernel as you see fit. I just compile stuff into the kernel ... modules are for sissy's ... however, the Debian kernel package tool doesn't care if you're a sissy ...

Once you have configured and saved your kernel config you run the following in /usr/src/linux:

make-kpkg kernel_image

This will commence to install the debian specific directory with configs, make sure you have a .config present and then build the kernel image. The kernel image will be /usr/src/kernel-image--.deb. You can install this kernel using 'dpkg -i kernel-image...deb' from the command-line. If you are installing this kernel on another machine you'll probably want the kernel headers as well so compilation of software that needs it will work correctly. To build that you run the following in /usr/src/linux:

make-kpkg kernel_headers

Same deal; it will make a .deb named accordingly that you can run dpkg -i on.

So that's all well-and-good but its technically more of a pain than just doing make; make bzImage; make install ... but there is a method do the madness. The real benefit comes when the next kernel revision comes.

Upgrading a Kernel

Let's say you compiled v.2.4.16 and then v.2.4.17 comes out. Let's just say you really need the features in v.2.4.17 so you go ahead and decide to build it.

Grab the new source and put it in /usr/src/linux (moving the v.2.4.16 out of the way). Copy /usr/src/linux-2.4.16/.config to /usr/src/linux (where /usr/src/linux is the v.2.4.17 kernel source).

Now run:

make-kpkg kernel_image

The kernel package will then commence to parse your .config, diff it with the new one, prompt you with anything that is new or changed and then proceed to build the actual kernel image placing it at /usr/src/*.deb as listed above.

Now you can install the new kernel with dpkg -i if you want ... same goes for the kernel_headers.

Another nice thing about using the kernel package for Debian is that it also update your LILO (assuming that is your bootloader). So it will move your old kernel to LinuxOLD and and run 'lilo' for you. That way, if you screw up your kernel you can revert to a working one without having to smack yourself on the head for totally hosing your machine.

Alright, that's about all I've got on kernel mojo ... I think I went a little overboard but I'm saving this for me too ...

Warning for the dumb like me ;^) - do this twice with non-bootable kernels, and you're hosed. Better to edit lilo.conf yourself - don't forget to run lilo.

I keep running into a kernel panic. I've diff'd against known good configs (on my Dell PowerEdge 750 with SATA), and still no joy. I'm using 2.4.27, which I understand should have libata included (and seems to, yup). I'm getting VFS: Unable to mount root fs on 08:0a. All my partitions are ext3 - could that be a problem? (Yes, I have ext3 built in).

Also, for completeness, I found this alternative method:
http://linuxheadquarters.com/howto/tuning/kernelcompilation.shtml

Neither one works for me 8^(


marc

Posted by Marc Byrd at Sep 07, 2004 21:30 | Permalink

I just wanted to let people know that this is an extremely helpful document when trying to build your Dell's custom kernel. All I can say is, don't fear the kernel compile! As long as you read, then read it again, it goes fairly smoothly.

I'm just installed Scott's debian-dell-2.4.28.iso on my two Dell PowerEdge 750 servers, a 3.4GHZ P4, 8GB Ram, Dual SATA 160GB Drives, using a PCIX 3ware 8000 series hardware RAID controller. And the other is a 2.8GHZ, 4GB Ram, and ditto on the 160GB's, and 3ware 8000... grin ...

... back to the kernel compile. Scott's ISO is currently running the 2.4.28 (As of Jan/27/05 the latest 2.4 on kernel.org is 2.4.29), so its fairly up to date, and worked well with my 3ware cards. I did have to enable the "e1000" network module during the install process though, this was required to get on the net, for the "network" install.

I did a 2.4.28 kernel compile using these instructions, and forgot to add in the 3ware module, oops! It was also late in the evening an my brain was in standby mode, so I botched up my lilo.conf, then "accidentally" deleted the /boot/mlinuz-2.4.28-bf2.4 file... so it was kernel panic time. Yay!

So long story short, I ripped out Scott's debian boot CD, ran the restore, fired in my /boot path in, re-compiled the kernel WITH the 3ware RAID controller. Rebooted, and I was back up and running!

---------------------------------------------------------------------------------------

I also found this handy HOW-TO: https://manuel.kiessling.net/topics/linux/debianinstall/

It gives you some info on patching the source 2.4.28 kernel to support the 3ware 9xxx Series RAID controller. If you follow these instructions:

"Get the patch that adds the 3w-9xxx driver to the kernel source: 3w-9xxx-2.4.28.diff
Place it in /usr/src, too. Patch the kernel source: in /usr/src, execute: bash:~# patch -p0 < ./3w-9xxx-2.4.28.diff Run "make menuconfig" in /usr/src/linux-2.4.28." + "make-kpkg --append-to-version='-bf2.4' kernel_image"

then:

"make-kpkg kernel_image: Run "dpkg -i /usr/src/kernel-image...deb" from the command-line. Check your lilo, and symlinks so you feel all warm and fuzzy inside.

Reboot, cross your fingers, breath a sigh of relief, then grab a beer!

Posted by Chris Fazekas at Jan 26, 2005 21:59 | Permalink

Just a quick update, following the above instructions I have compiled the new 2.4.29 kernel, it lists some bug fixes for the e1000 ethernet card, which I think is important as many of the Dell PowerEdge servers use it.

I'm going to start working on making an 2.6 kernel soon. And maybe a Apache 2.0. Debian is nice, but sometimes I wonder why they are still using 2.4 and apache 1.3?

Posted by Chris Fazekas at Jan 31, 2005 06:20 | Permalink

work perfectly for me !

Posted by frederic at Mar 22, 2005 03:46 | Permalink

This is truly a prime resource, short and to the point. I just want to join in on the choir of praise for Scott's ISO that still is the only solution I can find to get Debian to install directly to a SATA drive with a minimum of hassle. The only way for a newb like me.

I was trying to get Debian going on a Dell PoweEdge SC 420 with SATA drives. The integrated NIC (broadcom) uses the T3 network driver in case someone else is using the same kind of machine.

In case this is the very first time you are baking a new kernel there is also another page that really holds your hand through the whole process. Just another resource that I found to be very helpful, it's titled: The Very Verbose Guide to Updating and Compiling Your Debian Kernel

Posted by Mike Sarabia at Jun 09, 2006 01:16 | Permalink

The name of the network driver above is Tg3.
My mistake

Posted by Mike Sarabia at Jun 09, 2006 01:29 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.7 Build:#524 Jul 28, 2006) - Bug/feature request - Contact Administrators