********************************************** * Building a patched kernel on your own. * * (vserver, xen, xen-vserver, bigmem, smp) * ********************************************** Nagy Elemer Karoly, 2007. May 04., LGPL Short version for vserver only: apt-get install linux-tree-2.6.18 cd /usr/src/kernel-patches/all/2.6.18/debian/series/ grep -iR vserver * find /usr/src/kernel-patches/ -name "*vserver*" cd /usr/src/linux bzcat ../kernel-patches/all/2.6.18/debian/debian/vserver-version.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/features/all/vserver/vs2.0.2.2-rc9.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/features/all/vserver/bindmount-dev.patch.bz2 | patch -p 1 # Patch level 12: bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/cross-context-renice-fix.patch.bz2 | patch -p 1 # Patch level 13: bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/cacct-overflow.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/locks.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/net-mount-fix.patch.bz2 | patch -p 1 make-kpkg binary-arch NOTE: Kernel version 2.6.18 is used all through this document. 1. Introduction There are multiple linux-images (flavours) in Debian 4.0 Etch but there is only one linux-tree (source). Some image flavours (smp) are compiled from the standard source, while others (xserver, xen) are compiled from a patched source. So, if you need a specific flavour of the linux-image but you can't use or don't want to use the stock kernel, you need to patch the source. Debian collects it's patches (diffs between the "vanilla" Linux kernel and the Debian kernel) in the linux-patch-debian package (linux-tree = linux-patch-debian + linux-source). Some of these patches are already applied in linux-source and some are not. The applied patches are applied in series, so if you apply one "series" file, it will apply a bunch of patches. In the linux-patch-debian package, there is also an "apply" and an "unpatch" script that applies or unpatches all debian patches (so, by downloading a vanilla kernel source and running apply, you'll get a Debian kernel source). 2. Get kernel and patches So, after doing apt-get update ; apt-get install linux-tree-2.6.18 run cat /usr/src/kernel-patches/all/2.6.18/debian/series/12 to see the "12" patch series. This is not very interesting, but cat /usr/src/kernel-patches/all/2.6.18/debian/series/1-extra is - you can see that "debian/vserver-version.patch" is only applied to images "*_vserver" and "*_xen-vserver" - so if you want to build an official-grade xserver image, you need to apply this "debian/vserver-version.patch" (and the kernel won1t compile otherwise!). You can install a clean source by apt-get update ; apt-get install linux-source-2.6.18 and then unpack it bunzip2 linux-source-2.6.18.tar.bz2 ; tar -xf linux-source-2.6.18.tar and create a "linux" symlink: rm /usr/src/linux ; ln -s /usr/src/linux-source-2.6.18 /usr/src/linux 3. Locating patches Now, let's take a look on which patches we need: cd /usr/src/kernel-patches/all/2.6.18/debian/series/ grep -iR vserver * It is usually a good idea to follow the order of the patches (the number of the series). Patches are relative to "/use/src/kernel-patches/all/2.6.18/debian/" as shown by find /usr/src/kernel-patches/ -name "*vserver*" 4. Applying invidual patches So, let's patch a few to get a vserver: cd /usr/src/linux bzcat ../kernel-patches/all/2.6.18/debian/debian/vserver-version.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/features/all/vserver/vs2.0.2.2-rc9.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/features/all/vserver/bindmount-dev.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/cross-context-renice-fix.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/cacct-overflow.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/locks.patch.bz2 | patch -p 1 bzcat ../kernel-patches/all/2.6.18/debian/bugfix/all/vserver/net-mount-fix.patch.bz2 | patch -p 1 And voila - the patched kernel is ready. There is a lot more about patching in /usr/src/linux/Documentaition/applying-patches.txt 5. Configure, build, install Now, let's configure our kernel by: cd /usr/src/linux ; make menuconfig and get make-kpkg, a wonderful tool to automate kernel compilation and installation: apt-get update ; apt-get install kernel-package Let's create the kernel packages: make-kpkg binary-arch Finally, installation: cd /usr/src dpkg -i my_kernel_package.deb If you have gzconfig support, you can get your current config by zcat /proc/config.gz >/usr/src/linux/.config.my 6. Module-assistant Also, if you need funny stuff like ndiswrapper, you should get module-assistant as: apt-get update ; apt-get install module-assistant Get available extensions by: m-a list And download, build and install them automatically (after a reboot): m-a a-i ndiswrapper 7. Notes That's all, forks. Changelog: 2007 May 04 - Version 1.0 2007 Sep 09 - Version 1.1 (added patch level 12 and 13)