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?
Main Topics
Browse All TopicsI 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.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
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.
oops there are some typos on my previous post. First of all when I'm talking about 2.6.20 kernel and 2.6.19 kernel with patch-2.6.20 is the same thing. So in standard kernel jargon a patch means some part of code that modifies the previous version so that it updates the previous version to be the current version. So this is why if you have the spruces for 2.6.19 and you need 2.6.21 you fest apply the 2.6.20 patch to 2.6.19 and change it into 2.6.20. Then you'll apply patch 2.6.21. Another alternative to that is go and download the kernel-2.621 directly instead of struggling with patches. In both methods you'll end up with exactly the version kernel sources.
Nowadays you rarely need to compile your kernel. Because all major distros have their maintainers and they are following the changes day-by-day and they make the necessary modifications to their kernels over time. Since they are doing this for you so you won't need to do it on your own and when you need some specific things you'd better go with Distro supplied default sources not to break its integrity.
If you want to go beyond it is still ok but it takes you to turn into a kernel developer yourself.
Business Accounts
Answer for Membership
by: KeremEPosted on 2009-05-18 at 10:08:21ID: 24414081
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.