blog qmail quick facts connection problems free dns short urls open dns http proxy linux news 
  2005-05 
  2005-06 
  2005-07 
  2005-08 
  2005-09 
  2005-10 
  2005-11 
  2005-12 
  2006-01 
  2006-02 
  2006-03 
  2006-04 
  2006-05 
  2006-06 
  2006-07 
  2006-08 
  2006-09 
  2006-10 
  2006-11 
  2006-12 
  2007-01 
  2007-02 
  2007-03 
  2007-04 
  2007-05 
  2007-06 
  2007-07 
  2007-08 
  2007-09 
  2007-10 
  2007-11 
  2007-12 
  2008-01 
  2008-02 
  2008-03 
  2008-04 
  2008-05 
  2008-06 
  2008-07 
  2008-08 
  contact us 
  some jokes 
  song lyrics 
  public key 


  

  

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:

  1. the user has the source code for the kernel to the current major version
  2. the user has the patch program
There might be less reason to do this now because the world has changed, and for some bandwidth is cheap.

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