Howto build a custom kernel the debian way: I'm going to build the latest 2.6.x kernel from http://www.kernel.org.
The actual kernel list:
Get the kernel source
wget http://www.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2 wget http://www.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2.sign
Validate the downloaded source tarball - if gpg is not installed run
apt-get install gnupg. See http://www.kernel.org/signature.html for 'Linux Kernel Archives Verification Key'.
# import gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E gpg: key 517D0F0E: public key "Linux Kernel Archives Verification Key <email@example.com>" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 # Verify gpg --verify linux-2.6.18.tar.gz.sign linux-2.6.18.tar.gz gpg: Signature made Wed Sep 20 06:00:41 2006 CEST using DSA key ID 517D0F0E gpg: Good signature from "Linux Kernel Archives Verification Key <firstname.lastname@example.org>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: C75D C40A 11D7 AF88 9981 ED5B C86B A06A 517D 0F0E
Compile & Install
First make sure you have the needed packages installed:
apt-get install kernel-package libncurses5-dev fakeroot
Unpack the tarball:
cd /usr/src tar xjf linux-2.6.18.tar.bz2 cd linux-2.6.18
Configure your kernel
Either do this from scratch running a fresh
make menuconfig or copy the actual kernel config of your running kernel from
/boot/config-2.6.X to your
kerneltree/.config. But don't mix kernel releases (2.4 and 2.6)! Now you can run
make menuconfig and check your settings which should meet the old kernel config. Some options disappear from release to release but the new kernel should work as expected.
Create your kernel package.
CAUTION: Use the
–initrd option ONLY if your bootloader configuration uses initrd!
REVISION=$(date +%Y%m%d.%H%M) make-kpkg --rootcmd fakeroot clean make-kpkg --rootcmd fakeroot --initrd --revision $REVISION --append-to-version -lisa kernel-image # "--append-to-version -lisa" is optional and helpful if you compile a kernel for a special machine (lisa) # uname -nr will show something like this: lisa 2.6.18-lisa # Install the new kernel: dpkg -i linux-image-2.6.18-lisa_20060925.1620_i386.deb
To make your create process more convenient you can put some preferences into
# This file is used by kernel-package (>2.0) to provide a means of the site # admin to over-ride settings in the distributed debian/rules. Typically # thus is used to set maintainer information, as well as the priority # field. However, one may hack a full makefile in here (you should # really know what you are doing here if you do that, though) # Please change the maintainer information, as well as the Debian version # below, (and maybe the priority as well, especially if you are uploading # an official package) # The maintainer information. maintainer := yourname email := email@example.com # Priority of this version (or urgency, as dchanges would call it) priority := Low # This is the Debian revision number (defaulted to # $(version)-10.00.Custom in debian/rules) You may leave it commented # out if you use the wrapper script, or if you create just one # kernel-image package per Linux kernel revision # debian = $(version)-10.00.Custom debian = $(shell date +%Y%m%d.%H%M) root_cmd = fakeroot kpkg_follow_symlinks_in_src := YES CONCURRENCY_LEVEL := 3
This will break down the creation process to the following commands:
make-kpkg clean make-kpkg --initrd --append-to-version -lisa kernel-image
And finally make sure your kernel will boot! Have a look at your grub or Lilo configuration.
Setup your build environment
It is recommended to NOT do all the work above as root. Do this as a normal user. If you want to reuse your kernel sources for multiple hosts you can do:
lndir from the xutils package and follow these instructions:
# unpack kernel source as usual tar xjf /usr/src/kernel-xyz.bz2 mkdir kernel-hostname cd kernel-hostname lndir ../kernel-xyz [...] # make sure to instruct make-kpkg to use your symlinks make-kpkg [...] kpkg_follow_symlinks_in_src=YES kernel-image