Saturday, March 1, 2008

Patching Linux Kernel

Patching linux kernel is so simple.
First, You must download the kernel and the patch (of Course !),
Then, Applying the patch, simple is it? he... he... he...

For Example on my Slackware 12.

My slack comes with kernel 2.6.21.5 and i want to use the new one, like 2.6.23,
So i must get the pacth-2.6.21.5, patch-2.6.22, patch-2.6.23 from www.kernel.org/pub/linux/kernel/v2.6

Now, how to applying the patch
extract the patch wherever you want,
go to /usr/src/linux-2.6.21.5 and apply the patch
$cd /usr/src/linux-2.6.21.5
$su
password:
#patch -p1 -R < /path/to/patch-2.6.21.5
#patch -p1 < /path/to/patch-2.6.22
#patch -p1 < /path/to/patch-2.6.23
#mv linux-2.6.21.5 linux-2.6.23
Edit symlink 'linux' to the new kernel source 2.6.23
now you have the new kernel 2.6.23

applying patch for branch from 2.6.23 2.6.23.9
download patch-2.6.23.9
extract the patch
$cd /usr/src/linux-2.6.23
$su
#patch -p1 < /path/to/patch-2.6.23.9
#mv linux-2.6.23 linux-2.6.23.9
Edit symlink 'linux' to the new kernel source 2.6.23.9

applying patch for branch from 2.6.23.9 to 2.6.24
download patch-2.6.23.9 and patch-2.6.24
extract the patch
$cd /usr/src/linux-2.6.23.9
$su
#patch -p1 -R < /path/to/patch-2.6.23.9
#patch -p1 < /path/to/patch-2.6.24
#mv linux-2.6.23.9 linux-2.6.24
Edit symlink 'linux' to the new kernel source 2.6.24

note:
patching from 2.6.21.5 to 2.6.21.7, just go through (-p1)
patching from 2.6.22 to 2.6.23, just go through (-p1)
patching from 2.6.23 to 2.6.23.9, just go through (-p1)
patching from 2.6.23.9 to 2.6.24, first you must reverse the 2.6.23.9 to 2.6.23 by
applying patch-2.6.23.9 (-p1 -R) then patch-2.6.24 (-p1).

Happy hacking :>

No comments: