Jeff McCune 26 December 2003 Columbus Linux Users Group Online version available: (http://www.iwaynet.net/~dollzerr/colug_debian_2.6.0.txt) Rough Outline for compiling Debian Kernel Packages with the 2.6.0 Kernel This document will describe the "Debian Way" to produce a kernel, source, headers, and doc package which can be installed using dpkg or placed in a repository for apt. Debian provides a software package called kernel-package which greatly automates the task of kernel compilation. This program is responsible for producing the kernel-* (image, source, headers, and doc) packages. Once you apt-get install kernel-package, you should have everything necessary for the build phase of the process. Before actually deploying the kernel packages produced, an upgraded version of the module-init-tools package must be installed or the installation will fail when depmod tries to figure out module dependencies. This doc is based on a Debian testing (sarge) system, but should work fine with stable (woody) and unstable (sid). The only gotcha might be that an updated module-init-tools package might not be available yet for woody. Furthermore, kernel-package should be able to run completely as a normal user if fakeroot is installed, but I just decided to produce the packages as root to save myself some headaches. The docs for kernel-package should provide enough information for performing these steps as a normal user. Finally, if you're building a large number of kernels for multiple machines or architectures, this process can be further automated with the kernel-lab package, which is beyond the scope of this document. A good reference for 2.6.0 compilation is at http://kerneltrap.org/node/view/799 which is slightly more in-depth than this document, but not debian-specific. This document doesn't cover the kernel-patch or kernel-modules functionality of make-kpkg. If you need to compile third party modules along with the kernel packages please check specific documents for this. In particular, Nvidia GPU owners might check: http://www.minion.de/nvidia.html for patches to get nvidia modules compiled under 2.6. Please read the make-kpkg docs for how to compile the modules_image target to produce 3rd party modules the "Debian Way" Step 0: Backup important data. Step 1: Install necessary packages apt-get update && apt-get install kernel-package gnupg bzip2 Step 2: Get, verify and unpack a stock kernel tarball of 2.6.0 (become root) cd /usr/src/ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.0.tar.bz2 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.0.tar.bz2.sign gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E gpg --verify linux-2.6.0.tar.bz2.sign linux-2.6.0.tar.bz2 tar xvjf linux-2.6.0.tar.bz2 Step 3: Configure the kernel Kernel-package can optionally configure the kernel for you using the make-kpkg --config (menuconfig,config,oldconfig,xconfig,gconfig) option, however I prefer to do it by hand before running make-kpkg. If you plan to make a kernel package similar to how debian configures them, you can copy the current config settings and "import" them into the new kernel: cd linux-2.6.0 cp /boot/config-`uname -r` .config; make old-config You can then tweak the kernel to your liking using the normal kernel configuration methods: make menuconfig Once you have a kernel configured to your liking, it's time to build the packages: Step 4: Build the kernel Here, we actually run make-kpkg to build the packages to install. The two options which were most confusing to me are the --append-to-version and the --revision flags. This former specifies a tag to append to the version string for the kernel. For example, I use the pattern: -ARCH-EXTRAS-silas-VERSION for example -i686-smp-silas-2 for my third attempt at building an SMP kernel for i686. This produces a uname -r string of: 2.6.0-i686-smp-silas-2. The revision flag specifies the version tag of the package itself for dpkg and apt to reference. I usually use the pattern: 2:2.6.0.silas.VERSION where VERSION is the same as I used in the --append-to-version The tag before the : is the epoch, which is sort of strang and something I don't entirely understand, but I *think* you should just use something non-zero, or leave it out entirely. These patterns are just personal preference really, so make them whatever pleases you. The other options here can be referenced in the make-kpkg man pages, but are pretty self-explanitory. Next, build the packages: make-kpkg --initrd --bzimage --append-to-version -p3-smp-silas-2 \ --revision 3:2.6.0.silas.2 buildpackage Buildpackage is a target that actually runs clean and then binary. Binary is a target that actually runs the targets kernel_source, kernel_headers, kernel_doc and kernel_image which produce the *.deb files for each respective target. Hopefully the packages built without errors... If not, diagnosing the problem is beyond the scope of this document, but the usual way I fix them is to try remove some modules from the config, as they sometimes seem to interfere with each other. Step 5: Install the packages which the kernel-image-*.deb depends on: If you use dpkg, it won't try to satisfy dependencies, so we need to do this by hand. If you put these packages in a repository, apt should take care of this for you (Except for module-init-tools). apt-get install initrd-tools module-init-tools In woody, I think modutils is the package they use rather than module-init-tools, but again I'm not sure about this process in woody. Step 6: Install the kernel image itself dpkg -i ../kernel-image-2.6.0-p3-smp-silas-2_2.6.0.silas.2_i386.deb It might warn you about initrd lines needing to be added to lilo. Go ahead and proceed, as we will update lilo.conf to include these. I usually don't let dpkg run lilo for me, as I configure and run it manually, but that's just me. If you plan to use the symlinks in / then by all means... You just need to edit /etc/lilo.conf and make sure that there's an initrd=/initrd.img line for the first kernel definition. Step 6: Configure lilo I personally don't use the debian system of having one main kernel, and one "old" kernel in lilo.conf and dpkg rotating the symlinks in / every time a new kernel is installed. My lilo.conf looks like so: lba32 boot=/dev/hda root=/dev/hda3 map=/boot/map delay=20 prompt timeout=150 vga=normal append="" bitmap=/usr/share/lilo/contrib/sid.bmp bmp-colors=1,,0,2,,0 bmp-table=120p,173p,1,15,17 bmp-timer=254p,432p,1,0,0 install=/boot/boot-bmp.b image=/boot/vmlinuz-2.6.0-i686-silas-2 label=Linux-2.6.0-s2 read-only initrd=/boot/initrd.img-2.6.0-i686-silas-2 image=/boot/vmlinuz-2.4.22-1-k7 label=Linux2422-k7 read-only initrd=/boot/initrd.img-2.4.22-1-k7 optional image=/boot/vmlinuz-2.4.22-03082803-k7-smp label=Silas2422 read-only initrd=/boot/initrd.img-2.4.22-03082803-k7-smp optional Run lilo, and that should be it. Reboot, and test the new kernel. You'll need to be aware that module names have changed for a lot of things.