April 26, 2019

Custom Linux Kernels with Debian and Fedora

The Debian Way of Customizing Kernels

  • August 9, 2007
  • By Carla Schroder

Earlier this week we took a tour of the generic way of building custom Linux kernels. Today we'll look some nice Debian shortcuts, and Fedora's unique way of building custom kernels.

The Debian Way of Customizing Kernels

Debian's kernel source packages are named linux-source-[version]. The current official source package versions are linux-source-2.6.18 (stable), linux-source-2.6.21 (testing and unstable), and linux-source-2.6.22 (unstable and experimental).

Binary Debian kernel packages are named linux-image-[version]. It's been this way since version 2.6.12, if you're remembering the olden days of the kernel-source and kernel-image packages. The new naming convention opens the door to using other kernels with Debian, which I don't know what those would be, but Debian is ready for them.

To get started, install a build environment (see part 1), plus your kernel sources and the fakeroot package:

# aptitude install linux-source-2.6.22 kernel-package fakeroot

This downloads the source tarball into /usr/src/ where we do not want it, so you need to move it to your personal kernel-building directory:

# mv /usr/src/linux-source-2.6.22.tar.bz2 ~/kernel

Change to your personal kernel-building directory and unpack the tarball:

$ tar zxvf linux-source-2.6.22.tar.bz2

Then change to the top-level source directory and start configuring your new kernel:

$ cd linux-source-2.6.22
$ make mrproper
$ make xconfig

When you're done slogging through configuration, run these commands:

$ make-kpkg clean

$ make-kpkg -rootcmd fakeroot -rev kernel.1 linux_image

fakeroot gives you enough root privileges to build kernels as an ordinary user. It won't let you run commands that need genuine root privileges, but it's good enough for kernel-building. This leaves you with a .deb package named linux-image-2.6.22_kernel.1_i686.deb. Of course you may make the -rev option say whatever you want. Then install it in the usual way with dpkg:

# dpkg -i linux-image-2.6.22_kernel.1_i686.deb

This installs the modules and handles module dependencies, creates a boot menu entry, and copies the kernel and related file to the /boot directory. Now you can reboot, select your new kernel from the boot menu, and play with your new kernel.

Most Popular LinuxPlanet Stories