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

Posted on 2009-05-18
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 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
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 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 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.
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.


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 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.

Author Closing Comment

ID: 31582655
Thank you that answered my question.

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

822 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