5

I am following the instructions located here to setup my server. It states that I have to apply a patch which I've downloaded onto the machine. My question is, the article says to use the following command:

/usr/src/linux # patch -p1 < file.diff //note I replace file.diff w/ routes-2.6.36.16.diff

This returns:

-bash: /usr/src/linux: No such file or directory

I go on to assume that /linux # should be replaced with the actual linux kernel version/dir. I've tried this using the following command:

/usr/src/linux-headers-2.6.35.22 patch -p1 < file.diff

This returns the same. When I view the contents of /usr/src I only have two directories linux-headers-2.6.35.22 and linux-headers-2.6.35.22-generic-pae I need guidance as to the correct way to apply a patch to the kernel.

Edit

If I execute /usr/src/linux-headers-2.6.35.22/ patch -p1 file.diff I get -bash: /usr/src/linux-headers-2.6.35.22: is a directory. I need to know how I go about finding the specific file that needs to be patched here...

3 Answers 3

5

You need to download the source. You can do this via apt-src but I would (personally) just grab the latest from kernel.org, extract it, patch it (just using local paths like the desktop, it doesn't need to be hidden in /usr/src at all!) and follow the "old fashioned way" instructions for compiling it.

Note that some patches are only for certain versions of the kernel (this includes point releases) so make sure your patch works for the source version before you waste 20-30 minutes compiling it.

But your specific problem is you need to be in the directory that you want to apply the patch to. In your case:

cd /usr/src/linux-headers-2.6.35.22/
patch -p1 < /path/to/file.diff

Obviously change the path to the patch (or stick it in the same directory). If the source files are owned by root, prefix sudo onto the patch command or run sudo su to become root while you do this.

2
  • Thanks, that's working...to a point. I am not getting a message that patch is not installed... sudo apt-get install patch comes back unable to locate package. I am running ubuntu server 10.10 and on setup i did not select any specific function (dns, lamp, etc) do I need to install a package manager?
    – jon3laze
    Nov 3, 2010 at 22:31
  • You need build-essential IIRC but you'll need a lot more for building the kernel. Run this: sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
    – Oli
    Nov 3, 2010 at 22:37
3

To avoid frustration, you should generally do such things the Ubuntu way. Full instructions using official packages can be found here:

https://help.ubuntu.com/community/Kernel/Compile

It provides lists of dependencies and step-by-step commands for getting a custom kernel up and running.

By following that procedure, you will end up with an uninstallable package containing your custom kernel, which means that you will be able to switch back to the official kernels in future if needed.

4
  • These instructions are now a couple of years out of date. The tools and package structure has changed somewhat since then. Do you know of any up-to-date instructions?
    – detly
    Jan 17, 2013 at 0:28
  • I can't find anything newer, so I suspect that's still the most accurate documentation. Jan 17, 2013 at 1:50
  • This should not be marked as solved. Doesn't answer the question just points somewhere with irrelevant info...
    – pst007x
    Oct 20, 2013 at 0:08
  • @pst007x , then post a new and more accurate answer instead. Oct 22, 2013 at 4:02
1

The instructions you are following are showing you the command-line prompt /usr/src/linux #, which is not something you type as part of the command. The command to type that will apply the patch starts at patch and continues from there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .