Quick guide to patching the linux kernel
I write this quick guide because some people out there might be
making the same mistake that I made for a while in my early days as a
linux system administrator (the good old days).
Patching the kernel relies on two things:
- the user has the source code for the kernel to the current major version
- the user has the patch program
already compiled a kernel from source
The only important thing to do here is take a copy of the kernel configuration. I also strongly advise that the kernel tree be purged at this time, simply as it makes the patching process that much easier.
cp .config .. rm -rf linux-x.y.z
working from scratch
First get the latest major version. The major version is the first three digits of the kernel, for example, 2.6.10 would be a major version, 2.6.10.1 would be a minor version.
Now we must get the patch file, this *must* be a minor version based on your major version. 2.6.10.5 would be the patch for 2.6.10.
so lets get on with it
In this example we're going to work from the 2.6.20 kernel.
cd /usr/src wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2 wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.20.9.bz2 tar -jxvf linux-2.6.20.tar.bz2 cd linux-2.6.20 bzcat ../patch-2.6.20.bz2 | patch -p1
This should bring you to the latest 2.6.20 release. Although some argue that it is not necessary, I prefer to remove the whole linux-2.6.20 branch each and every time I apply a patch to increase the minor number.
going forward
Patching is always incremental, except when incrementing the major number. When this happens the patch has to be applied to the version. For example, the 2.6.21 patch is applied against the 2.6.20 tree.
cd /usr/src wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2 wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.21.bz2 tar -jxvf linux-2.6.20.tar.bz2 cd linux-2.6.20 bzcat ../patch-2.6.21.bz2 | patch -p1

