Link to home
Start Free TrialLog in
Avatar of yami_rider
yami_rider

asked on

Cannot patch linux kernel on CentOS 5.3 (Can't find file to patch at input line)

I am trying to patch a Linux kernel (2.6.18 <-- 2.6.29) on CentOS. However I am getting the error message "Can't find file to patch at input line".

Steps: (CentOS 5.3)
1. Downloaded from kernel.org the patch-2.6.29 and placed this file at /usr/src/kernels
2. Performed gunzip to uncompress patch.
3. Currently there are two folders within /usr/src/kernels named (2.6.18-128.1.10.el5-i686 and 2.6.18-128.el5-i686)
4. Next I change directories into one of the above subfolders (cd 2.6.18-128.el5-i686)
5. I issue the command patch -p1 < ../patch2-6.29 and I receive an error message stating

"Can't find file to patch at input line"
The text leading up to this was:
------------------------------------
|diff --git a/,mailmap b/mailmap
|index 97f7b4f..a62e6a8 100644
|--- a/.mailmap
|+++ b/.mailmap
------------------------------------
File to patch:


I have tried this from the other folder as well. I have also reviewed most of the HOWTO faq's on the internet regarding how to patch the kernel.

Is there something that I am missing here or is the patch simply not working? Any help would be greatly appreciated.
Avatar of Kerem ERSOY
Kerem ERSOY

You can't directly apply patches for whateverversion you have to whatever version you want. If you'll go with pathces you need to get sources from the same source and also you need to apply all the patches. You need to apply pattch 2.6.19, 2.6.20, 2.6.21, 2.6.22, 2.6.23 up t1o 2.6.29.  

Apart from that the patches are for the standard kernels. But you have kernel patched by Red-HAT. So  even if your patch was for the 2.6.19 it would not work. You need to get a kernel source from kernel.org and go with the patches from there too. Otherwise you can not succeed.

So instead of trying to patch the kernel get the sources from the kernel.org then set compilte time oprtions before make. if you want get the configuration from your Red-HAT sources directory and issue:

make oldconfig
make
make modles

If you need make initrd and you're ready to go.

Cheers,
K.
Ouch!  Patching kernels manually is not to be done lightly unless you are very familiar with what you are doing.

Why do you want to patch your kernel?  Is there something specific a CentOS update doesn't cover?
Why will not You get the linux-2.6.29 sources tarball - why patch?
Anyway, centos kernel(RH in fact) is heavily patched already, so applying patch-2.6.19 and next will surely fail.
Avatar of yami_rider

ASKER

The system I am working on is a test system and I am for learning purposes trying to wrap my head around the kernel.

So this is merely an excercise, but from what I can see a general rule of thumb (at least for CentOS) is that there is no need to patch the kernel.

My next question would be:

1. Assuming that you need to update your kernel, what is the best method, use the source tarball files or apply a patch?
1. When should you recompile the kernel, what scenarios would prompt someone to have to recompile the kernel?
2. Along those same lines, with respect to patching, when is it a good idea to patch your kernel?  Our mainsteam distributions (i.e. CentOS, RedHat, SuSE, etc) well maintained and therefore there is no need to tinker with applying kernel patches?
You might need to update the kernel. But RedHAT kernel is highly modified form the standard. UIt is why it takes a while to be available a bit later than  the kernel sources published.

When you need to build your kernels the best practice for RedHAT is either compile the available version in that RedHAT makes available both executable and sources available. so if you need to add something you just go add and recompile.

But it you need a kernel newere than RedHAT prresents you need to go grab the kernel sources. Patches are only for people already have the previous kernel and don't have so much badwith to download again. In the end  an 2.6.20 kernel and kernel 2-6-19 and applied 2-6-10 patches ate the same thing. So patches are not add some functionality they re what makes a kernel the next release. When it comes to RedHAT you really need to know waht you're doing since they are heavily patching the kernel instead og using a stock kernel. So you need to know what the system needs this is why I'd suggested the make oldconfig to be at least compiled with same options.

Wen it comes to when to compile a kernel is some time when you need an option but it is not available as a module. For instance if you need a kernel with a higher frequency to use in hi res time processing you need to compile kernel because the only wat to modify the interrupt processing is through compiling. But when you add a new hardware you'll only need a module for the drive.

As I told earlier to patch the kernel generally means an older version into a newer version. so you need to patch the kernel when you have oledr version of sources and to add the newer functionality. There are some other cases where patches are to modify some porperties of the jkernel but they are special pathced not kernel version patches. At least none of the patches you want ot deal with in your question was of this nature.

Distro maintainers apply the patches and makes modifications so that they prepare newer versions over time so generally yeah you don't need to build your own kernel for most of the time.
ASKER CERTIFIED SOLUTION
Avatar of Kerem ERSOY
Kerem ERSOY

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you that answered my question.