Kernel sources should be placed in /usr/src. So you should go into this directory then unpack the sources there:
$ cd /usr/src $ mv linux linux.old $ tar xjf /path/to/linux-2.4.20.tar.bz2 |
The command mv linux linux.old is required: this is because you may already have sources of another version of the kernel. This command will ensure that you do not overwrite them. Once the archive is unpacked, you have a linux-<version> directory (where <version> is the version of the kernel) with the new kernel's sources. You can make a link (ln -s linux-<version> linux) for commodity's sake.
Now, the patches. We will assume that you do want to patch from version 2.4.20 to 2.4.22 and have downloaded the patches needed to do this: go to the newly created linux directory, then apply the patches:
$ cd linux $ bzcat /path/to/patch-2.4.21.bz2 | patch -p1 $ bzcat /path/to/patch-2.4.22.bz2 | patch -p1 $ cd .. |
Generally speaking, moving from a version 2.4.x to a version 2.4.y requires you to apply all the patches numbered 2.4.x+1, 2.4.x+2, ..., 2.4.y in this order. To revert from 2.4.y to 2.4.x, repeat exactly the same procedure but applying the patches in reverse order and with option -R from patch (R stands for Reverse). So, to go back from kernel 2.4.22 to kernel 2.4.20, you would do:
$ bzcat /path/to/patch-2.4.22.bz2 | patch -p1 -R $ bzcat /path/to/patch-2.4.21.bz2 | patch -p1 -R |
If you wish to test if a patch will correctly apply before actually applying it, add the --dry-run option to the patch command.
Next, for the sake of clarity (and so you know where you are), you can rename linux to reflect the kernel version and create a symbolic link:
$ mv linux linux-2.4.22 $ ln -s linux-2.4.22 linux |
It is now time to move on to configuration. For this, you have to be in the source directory:
$ cd linux |