The default Linux kernel of Debian Lenny is of course very stable – but a little outdated. If you’re the more adventurous type (or just need support for newer devices) you might like the idea of installing a more recent vanilla kernel? Debian makes this task quite easy and you’ll end up with real Debian kernel deb-packages! I’ll provide a small HOWTO here which you might follow and a small script which will automate everything. I gathered most of the information given here from the official Debian documentation (have a look at this and this).
If you choose /usr/src as the source directory (which I strongly recommend), add yourself to group ‘src’ by
su -c "usermod -aG src <USERNAME>"
If you follow this, you don’t need to be root to build a new kernel – and that’s a good thing. Now import the Kernel Archive signing key to your gpg keyring (see this for details):
gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E
We need this to verify the integrity of the source tarball later on. So, download the kernel sources from https://www.kernel.org/ and the corresponding signature file from here to /usr/src. Then check the source tarball integrity by
gpg --verify linux-<VERSION>.tar.bz2.sign
and you should see something like this:
gpg: Signature made Mon Oct 9 23:48:38 2000 PDT using DSA key ID 517D0F0E
gpg: Good signature from "Linux Kernel Archives Verification Key <email@example.com>"
If not, something went wrong during your download and you have to try again.
We may now unpack the source code (still within /usr/src):
tar xvf linux-<VERSION>.tar.bz2
For a start, copy an old .config file to the kernel source tree. You may use the one from /boot of your current kernel. I tend to choose one from sidux‘ kernel, configured by slh. To do so, download a kernel package from one of sidux’ download mirrors and extract the content to a temporary directory, then copy boot/config-<WHATEVER_VERSION> to your kernel source tree as .config. For example, download “linux-image-2.6.29-1.slh.3-sidux-amd64_2.6.29-9_amd64.deb” and extract the content by:
dpkg-deb -x /path/to/linux-image-2.6.29-1.slh.3-sidux-amd64_2.6.29-9_amd64.deb test
cp .config-2.6.29-1.slh.3-sidux-amd64 /usr/src/linux-<VERSION>/.config
rm -r test
Proceed with configuring and compiling the new kernel:
You may tweak your kernel now. (The sidux kernel tends to have almost every module compiled, so you might want to deselect some modules which you don’t here). I’d recommend to change at least the processor type to match your actual CPU, i.e., “Generic x86_64” to “Athlon64” in my case. Now save your configuration and exit xconfig. (EDIT: optionally run ‘
make-kpkg clean‘, if you build multiple kernel packages with different configuration.) Let’s build the kernel package:
fakeroot make-kpkg --initrd --append_to_version -<YOUR_CHOICE> --revision=<YOUR_REVISION> kernel_image
The “–append_to_version” switch may be used to append the revision and architecture/CPU type to the kernel name. For example “custom.1-amd64-k8”. Replacing <YOUR_REVISION> with a revision number and kernel version is recommended, i.e. “220.127.116.11~custom.1”. Both fields may contain alphanumerics and “~ + .”, <YOUR_CHOICE> may also contain “-” (without the quotation marks!).
Whatever you choose, the former step may take a while, depending on your machine (it takes almost an hour on my computer – but I tend to compile a lot of modules, even those I might never need!) Once done, I’d recommend running almost the same command again but this time building a kernel header package:
fakeroot make-kpkg --initrd --append_to_version -<YOUR_CHOICE> --revision=<YOUR_REVISION> kernel_headers
You may repeat this with “kernel_doc” and “kernel_source”, too. You should end up with deb-packages in /usr/src, which can now be installed by
su -c "dpkg -i /usr/src/<package_name>.deb"
Your grub configuration will be automatically updated, just like with default Debian kernel updates – the Debian way! Once your new kernel is installed, remember to reinstall any proprietary drivers for your new kernel, like those by Nvidia or Ati.
Reboot to the new kernel and see if everything works… Good luck! 😉
As I’m kind of lazy, I decided to script this whole procedure, so I don’t need to remember everything. You may download this script from here and do with it almost everything you like (I do not know, if a license is required for a small script like this, but if so, it’s GPL’d 2, of course.)
This script basically does everything described above automatically. It asks for the desired kernel version, downloads it if required, checks the gpg signature, asks for the revision, starts xconfig and creates the kernel packages. Please open this script first in your favorite editor and have a look at a few configurable variables and maybe adjust them. Please take a look at the README file! You may then run this script (NOT as root) and it *should* work.
Download the script from here:
custom_kernel_0.51.zip (Version 0.51) (md5sum: f1991b1e9712d05a53c524b285c6c498)
custom_kernel.tar.gz (Version 0.5) (md5sum: aaa81f83d84ccd5b7e9fe14187f302f3)
custom_kernel.tar.gz (Version 0.4) (md5sum: b752d5d7f684d5ffb264b287f6b74472)
Disclaimer: This script is provided “as is”, I give no warranty whatsoever.