Solved

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

Posted on 2009-05-18
7
1,653 Views
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.
0
Comment
Question by:yami_rider
7 Comments
 
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
make modles

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

Cheers,
K.
0
 
LVL 48

Expert Comment

by:Tintin
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?
0
 
LVL 43

Expert Comment

by:ravenpl
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.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:yami_rider
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?
0
 
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.
0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 500 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.
0
 

Author Closing Comment

by:yami_rider
ID: 31582655
Thank you that answered my question.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now