Nearly Painless Kernels

Debian's Kernel Package Notes

Disclaimer: Since beginning to write this page I have switched to using the stock Debian kernel-image-* packages and they are working very well. The module packages that I used to compile such as ALSA, PCMCIA-CS, and LT-modem are now available as Debian packages. I do, however, still need to compile the Madwifi modules for my Atheros wireless card against the Debian kernel source package. :-(

A long time measure of a Linux geek's accumen has been the ability to "roll one's own kernel". Gone are the days when one had to cross the fingers in the hopes that one of the supplied kernels would even boot let alone support the CD-ROM to do the rest of the install. Then, if sound, bus mouse, PCMCIA, or some other hardware support was needed, a custom kernel was probably required. While the distributions do a good job of supplying a "vanilla" kernel that has support for a lot of hardware both compiled in the kernel and with modules, a custom kernel can possibly be more efficient and use less disk space.

Figuring out what to include in a custom kernel is daunting at first and reaching a useful set of configuration options is largely a method of trial and error. As a result, several series of configuration, compilation of both kernel and modules (plus ancilliary packages such as pcmcia-cs drivers, alsa drivers, Lucent modem driver, etc), copying all the files into the right place, running Lilo to install the boot loader, rebooting, and testing (whew!), the chance for a mistake rendering the newly compiled kernel unbootable is frighteningly high. What's the budding sys-admin to do?

Well, Debian to the rescue! The Debian maintainers have developed a package called kernel-package that goes a long way toward avoiding a missed step and integrates your custom kernel into the Debian package system just like the official kernel-image packages. Using kernel-package for ancilliary packages like Alsa drivers is much easier and integrates the drivers seemlessly into the kernel modules directory structure.

What this page is not; this page is not an exhaustive tutorial on kernel-package. Rather it is a quick reference with some amount of explanation thrown in. For a better tutorial see Creating custom kernels with Debian's kernel-package system and the documentation included with kernel-package. This material assumes you know how to install packages on your Debian system and are familiar with the boot loaders Lilo or Grub.

Getting Started

Kernel-package works well with either Lilo or Grub although the .deb package it builds will run lilo by default when installed. To turn off this behavior for those of us using Grub, edit (or create if necessary) /etc/kernel-img.conf and add (or edit):

do_boot_enable = No

Be aware that even if you have lilo installed and use it for your boot loader this command will prevent its configuration from being updated! Many more options exist for this file as detailed by man kernel-img.conf. I've found the other defaults to be satisfactory.

I'm not at all certain whether Kernel-package will work with a stock kernel release from I think a number of Debian patches need to be applied so I would suggest using the official kernel-source version of your choice from the Debian archive.

Configuring the kernel

Kernel configuration consists of using the standard kernel configuration tools such as make menuconfig (an ncurses (color character mode) configuration tool) or make xconfig (a TCL/Tk configuration tool). For more information on configuring the kernel and other issues see the Kernel-HOWTO.

Compiling the kernel

Once the kernel configuration is complete it's time to start building the kernel. Each invocation consists of one or options and a target. The first command cleans up the cruft left over from a previous compilation run:

make-kpkg clean

Then it's time to build the kernel:

make-kpkg --append-to-version=.YYMMDDv kernel_image

The kernel-package documentation suggests using the --revision= option. While it makes a uniquely named .deb package, it does not give the kernel binary or the other files a unique name, so newer kernels will clobber older ones. I found that using --append-to-version= avoids this problem nicely by giving the kernel binary, config file, file, the modules directory, and the documentation directory unique names allowing each of your custom kernels of a given version (e.g. 2.4.26) to peacefully coexist.

The YYMMDDv string is of my own design and you can use your own string so long as it meets the restrictions in /usr/share/doc/kernel-package/README.gz. In my string YY is the last two digits of the current year, MM is the current month (01-12) and DD is the day. The v is a letter (a-z) to cope with multiple builds on the same day.

Compiling the kernel modules

Next, build the modules:

make-kpkg --append-to-version=.YYMMDDv modules_image

It's possible that modules_image could be combined with kernel_image, but I prefered to do them seperately if debugging the process was necessary.

If you've decided just to build new modules and aren't changing the kernel, run:

make-kpkg modules_clean clean

and then:

make-kpkg --append-to-version=.YYMMDDv modules_image

as before.

Added modules

To compile added modules, those placed under /usr/src/modules, the command invocation varies a bit with the target specified after an option that specifies which module package to build:

make-kpkg --append-to-version=.YYMMDDv --added-modules=[alsa_driver|pcmcia-cs|madwifi|etc] modules_image

Use only one of the module packages listed with the --added-modules option. I'm sure there are more module packages that make-kpkg can build, these are just the ones I've built. For more information on the Madwifi source package for Debian check out Martin List-Petersen's Madwifi page.

Lucent software modem

My Thinkpad 390E laptop has a Lucent software modem that is well supported by a proprietary firmware module loaded by a GPL'ed driver. The source release has its own build script called build_deb. It will also build a Debian package like make-kpkg. Fortunately, there are Debian packages available that are built against the released Debian kernel packages so I no longer have to compile this either.

Finishing up

Once the kernel and module packages are built it is time to install them. Just use dpkg -i <package_name.deb> and start with the kernel and work through the module packages. Now that the packages are installed, run lilo or update-grub, reboot and enjoy the fruits of your labors.

Now, head for the fridge and get me a beer, will ya?

Take me back to the Index!

The Linux Webring:
[ Prev | Next | Random | List | Home | Stats ]

Original content Copyright © 1997-2017 Nate Bargmann NØNB
any other content copyright by respective author(s).

This page last modified
February 12, 2005
Valid XHTML 1.0! Valid CSS! Built with WSMake!