1

I am trying kernel patching for the first time. I am not sure the following is encountered with an error and if I am doing it correctly. But in all tutorials and videos shows, .patch extension files, but I have a .xz file.

Downloaded stable release 5.12.1 from https://www.kernel.org:

root@learn:/usr/local/src# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.1.tar.xz

root@learn:/usr/local/src# mkdir Linux-Kernel-5.12.1

root@learn:/usr/local/src# tar xvf linux-5.12.1.tar.xz -C Linux-Kernel-5.12.1/ --strip-components=1

root@learn:/usr/local/src# cd Linux-Kernel-5.12.1/

root@learn:/usr/local/src/Linux-Kernel-5.12.1# cp /boot/config-$(uname -r) ./.config

Downloaded the patch .xz file from https://www.kernel.org/ to the directory:

root@learn:/usr/local/src/Linux-Kernel-5.12.1# wget https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.12.1.xz

When applying:

root@learn:/usr/local/src/Linux-Kernel-5.12.1# patch -p1 < patch-5.12.1
patching file Makefile
Reversed (or previously applied) patch detected!  Assume -R? [n]

What does that mean?.

What am I supposed to do at that point?.

Also, for Ubuntu/Debian, is downloading stable kernel and its patch from https://www.kernel.org/ is the right way or does it have its own source URL other than kernel.org?.

3
  • One doesn't usually try to patch from one version to the exact same version they're already have. 5.12.1 to 5.12.1, what are you trying to accomplish?
    – yoonix
    May 6 at 16:08
  • I am learning Kernel patching. so you meant 5.12.1 must have the patch 5.12.1 in it right? In that case, patch 5.12.1 works on kernel 5.12, is that correct?.
    – JohnW
    May 6 at 16:20
  • The URL of the patch is wrong. I assumed you mean cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.12.1.xz and corrected your question. Feel free to rollback if I'm wrong
    – xhienne
    May 8 at 13:05
2

This error message

Reversed (or previously applied) patch detected!  Assume -R? [n]

... means that the patch command detected that your patch has already been applied to the sources. It suggests you to use patch -R but it's not what you want, since it would unapply the patch and thus you would get an earlier version of the Linux sources.

This is due to a misunderstanding of yours. Look at the first lines of the patch:

--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 12
-SUBLEVEL = 0
+SUBLEVEL = 1
 EXTRAVERSION =
 NAME = Frozen Wasteland

What this chunk does is changing the 4th line of Makefile so that SUBLEVEL goes from 0 to 1. In effect, this patch changes the Linux version from 5.12.0 to 5.12.1, the version you already have (hence the error message).

So, this is not the right patch. What you want is the 5.12.2 patch. But if you take a look at it (like above) you will realize it applies to the 5.12.0 source tree, not the 5.12.1 one:

--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 12
-SUBLEVEL = 0
+SUBLEVEL = 2
 EXTRAVERSION =
 NAME = Frozen Wasteland
2
  • Thank you :) Finally, someone is here to explain what I was stuck with. Happy learner here :)
    – JohnW
    May 8 at 13:28
  • My pleasure @JohnW :)
    – xhienne
    May 8 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.