How to patch the kernel

Source: Internet
Author: User

Purpose
This document is a simple guidance document. Teaches you how to patch your kernel. This is the most basic job in kernel development.
Patch is used to store files of different versions. By patching, you can upgrade the source code without downloading the entire source code.
For detailed patching methods, you can view the kernel/document/applying-patchs. Txt
Requirements
You should already have a compiled kernel. If not. You can download it at www.kernel.org. This article does not teach you how to compile the kernel
The kernel should be downloaded from kernelorg. Third-party kernels (such as RedHat) may cause problems during patching. Please refer to your patch article for special release.
Address: http://blog.csdn.net/hide1713/archive/2007/12/16/1941614.aspx

Scenario 1
Now the kernel source code is stored in my/usr/src/liunx-2.6.22.9. I went to www.kernel.org and saw that the latest stable version is
2.6.23.11. So how can I upgrade it?

First, versions like 2.6.x.x are called stable versions. It is proven stable by tests. Generally, users only use this version. Other versions include RC and mm. We will not discuss it here. 2.6.x is called the base stable version. The four-digit version is patched on the base stable.

Therefore, you must first downgrade to 2.6.22 and then upgrade to 2.6.23 in step 2.6.22.9. Then, upgrade to 2.6.23.9.
The procedure is as follows.

1.download patch-2.6.22.9.bz2. Put it in the/usr/src/directory.
Next
CD liunx-2.6.22.9
Bzcat ../patch-2.6.22.9.bz2 | patch-P1-R # Use the R command to remove the patch. In this way, we can reduce 22.9 to 22.

2.download patch-2.6.23.gz. Put it in the/usr/src/directory.
CD liunx-2.6.22.9
Zcat ../patch-2.6.23.gz | patch-P1 # Upgrade to 2.6.23

3.download patch-2.6.23.11.bz2. Put it in the/usr/src/directory.
Next
CD liunx-2.6.22.9
Bzcat ../patch-2.6.23.11.bz2 | patch-P1 # So upgrade to 2.6.23.11 which is now the latest version of stable.
Last
CD ..
MV linux-2.6.22.9 linux-2.6.23.11 # change to the correct directory name
Ln-s linux-2.6.23.11 Linux # rebuild Link

Scenario 2

If I want to upgrade 2.6.23.11 to 2.6.23.12, I should first roll 2.6.23.11 back to 2.6.23 and then apply the 2.6.23.12 patch.
Suppose I am already in the kernel directory. The patch is placed in the upper directory.
Bzcat ../patch-2.6.23.11.bz2 | patch-P1-R # Roll Back To 2.6.23
Bzcat ../patch-2.6.23.12.bz2 | patch-P1 # Hit 2.6.23.12

In general, this is the case. The correct output should all be like the following
Patching File Include/NET/sock. h
Patching File Include/NET/tcp. h
Patching File Include/SCSI/scsi_device.h
Patching File Include/xen/interface/vcpu. h
Patching file IPC/mqueue. c
Patching file kernel/exit. c
Patching file kernel/fork. c
Patching file kernel/futex. c
Patching file kernel/futex_compat.c
Patching file kernel/hrtimer. c
Patching file kernel/IRQ/manage. c
Patching file kernel/lockdep. c
Patching file kernel/Params. c
.
.
.
If the rej file appears. It indicates that some files failed to be patched. View the rej file. See why the failure occurs. In general. It may be that your directory tree is faulty. If you have any questions. Refer to the patch tutorial under the kernel/docmuent directory.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/hide1713/archive/2007/12/16/1941614.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.