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

Posted on 2009-05-18
Medium Priority
Last Modified: 2013-12-16
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.
Question by:yami_rider
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 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 modles

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

LVL 48

Expert Comment

ID: 24415605
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?
LVL 43

Expert Comment

ID: 24415646
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.
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!


Author Comment

ID: 24416408
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?
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24416699
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.
LVL 30

Accepted Solution

Kerem ERSOY earned 2000 total points
ID: 24416898
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.

Author Closing Comment

ID: 31582655
Thank you that answered my question.

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question