OpenSUSE patch tutorial (kernel2.6.x)

Source: Internet
Author: User
Tags andrew morton
OpenSUSE patch tutorial (kernel2.6.x) -- Linux general technology-Linux programming and kernel information. The following is a detailed description. [Note]: Some patches are very famous, such as CK.

What is the kernel?
The kernel is the core of a Linux system. It provides underlying functions such as hardware abstraction layer, disk and file system control, and multi-task concurrency management.

What is a patch?
The Linux Kernel is maintained by the Kernel Team (http://www.kernel.org) who provide the latest stable version of Kernel source code on the home page. This is the original pure kernel code.

As mentioned above, the original kernel is generally modified for various reasons. The source code modification is implemented by patching, and each kernel patch implements a specific function. The patch download addresses are scattered and self-search is more effective.

Compile the source code of the kernel that has been patched to obtain the binary file that can be recognized by the computer, which is the (finished) kernel we use everyday.

Why re-compile the kernel?
OpenSUSE has made many modifications to the kernel source code to improve the hardware compatibility and stability of the system. Conservative optimization parameters are also used during compilation. In this way, the kernel size is large and the running speed is slow, but the stability and compatibility are excellent.

There are three reasons for compiling the openSUSE kernel:

1. Improve kernel compatibility or add features

Despite many official openSUSE patches, they may still not meet user needs. You may need to install a specific patch or update the kernel version to support new hardware or add support for a software.

2. System Acceleration

As mentioned above, the performance of the official kernel is reserved. recompiling the kernel based on your hardware configuration and using appropriate optimization parameters is the most effective way to speed up the system.

3. Psychological Needs

People like Thruth, the author of this document, always want to use the latest kernel version and recompile the kernel repeatedly.

If the upgrade fails, how can I restore the official kernel?
Start SUSE Linux on the installation CD, and enable yast to refresh the kernel and related packages.

Compilation steps
Requirement
To compile the kernel, install necessary compilation software.

Binutils gcc make module-init-tools udev ......

Download kernel source code and patches
Obtain the kernel source code
For openSUSE users, there are five ways to obtain the kernel source code and patch. Please select as needed:

1. Use the official kernel-source package

Whether the kernel-source package comes with the installation disk or YaST-> Software-> the kernel-source package updated online, it is officially provided with the kernel source code that has been patched.

Note: This package is best consistent with the kernel-default package version in the system.

Advantages: it can be used directly and is secure and stable, with almost no errors

Disadvantage: The version will not be the latest and has been patched, so there is little room for performance improvement

Instructions for use: directly install and use

2. Use the src. rpm package of the official kernel-source

The SRC directory is always available on the official image website that installs or updates the source, including various software source code. You can find src. rpm of kernel-source.

For example, the file http://ftp.novell.co.jp/pub/suse/suse/update/10.1/ can be found in the rpm/src directory under an image kernel-source-2.6.16.21-0.13.src.rpm Of The SUSE 10.1 official update source

Note: After extracting the package, you must manually select the patch and move the directory. If you have no requirements for the kernel version, we recommend that you use this method to obtain the kernel source code and patches.

Advantage: the kernel and patch versions are the same, so the patching operation will basically not fail. Self-patching will significantly improve the performance.

Disadvantage: the version is not the latest and needs to be decompressed multiple times. You must have a certain understanding of the entire software and hardware system.

Usage: Decompress the file-roller or rpm2cpio command of the graphics program to a directory. The files to be used and comments are as follows:

Config.tar.bz2 # according to the system architecture classification of the config Kernel configuration file linux-0000.tar.bz2?original internal kernel code novell-kmp.tar.bz2 # Novell upgrade # kernel.org official version incremental upgrade patch (with the built-in sec. rpm does not have this file: patches.suse.tar.bz2 # SUSE dedicated patch patches.uml.tar.bz2 # Patches required for the UML patch patches.xen.tar.bz2 # XEN Virtual Machine
Extract the original kernel code to the/usr/src/directory. The kernel-source-2.6.16.21-0.13.src.rpm mentioned above is used as an example.

$ Tar jxf linux-2.6.16.tar.bz2 $ su # mv linux-2.6.16/usr/src/

3. Use the kernel-source package of the source suser-jengelh

This installation source is in the http://ftp-1.gwdg.de/pub/linux/misc/suser-jengelh/SUSE-10.1/

Note: The version is higher than the official version. It has multiple versions and contains the unstable version of the kernel. Do not use it unless you have.

Advantage: None

Disadvantage: the system architecture is incomplete. In most cases, only the 32-bit version is supported. Some patches and configuration files cannot follow up with the new version, which is very prone to various problems.

Usage: if you are not afraid of death, install and use it directly.

4. Use the src. rpm package of the source suser-jengelh kernel-source to be installed unofficial

This installation source is in the http://ftp-1.gwdg.de/pub/linux/misc/suser-jengelh/SUSE-10.1/, And the src directory contains many kernel-source. version. src. rpm

Note: The version is higher than the official version. It has multiple versions and contains the unstable version of the kernel. Do not use it unless you have.

Advantage: None

Disadvantages: Some patches and configuration files cannot be followed up with the new version, which is very prone to various problems.

Usage: if you are not afraid of death, use the official kernelsource src. rpm package.

5. manually download the original kernel code and patches

The original kernel source code is downloaded in the http://www.kernel.org, and patches are searched and downloaded or decompressed using the latest official src. rpm patch.

Note: using this method requires you to have a good understanding of your hardware and Linux system. Be careful when tossing. Generally, it's okay.

Advantages: flexibility, new version, and obvious Performance Improvement

Disadvantage: Some patches suitable for the latest version may not be found, so you must have a good understanding of the entire software and hardware system.

Usage: Decompress the downloaded Linux source code package to the/usr/src/directory. Here, the latest official stable version of the kernel is used as an example:

$ Wget http://www.kernel.org/pub/linux/... -2.6.18.tar.bz2 $ tar jxf linux-2.6.18.tar.bz2 $ su # mv linux-2.6.18/usr/src/
Patch the kernel source code
The original kernel source code has been put into the directory of/usr/src/linux-version. In the example used above, the source code using the official src. rpm should be in the/usr/src/linux-2.6.16 directory; instead, download the original kernel source code in the/usr/src/linux-2.6.18 directory.

The kernel source code upgrade may invalidate a patch, so it is not a patch that can "fill" all versions of the kernel. If the patch cannot be used on the new kernel, there are two situations: first, the kernel has been "supplemented" by the kernel, or the patch has expired the new kernel code. In any case, search for an error or create a new patch based on the original patch.

Select the required patch
This is a test of your understanding of the system, there are a lot of hardware and patches on the earth, the specific system and hardware selection and patches are not covered in this document. However, it is very easy to select the standard for patching. The first is hardware, the second is functional, and the last is psychological. There is no need to add all the patches. To put it simply, the more patches, the slower the system.

The hardware needs to be patched based on your hardware. A small part of the hardware uses the original kernel to cause disorder or weakness to varying degrees of functionality, and some do not affect normal use, but keep reporting errors in logs; in this case, you can use a patch to fix the problem.

A large number of patches exist in src. rpm of kernel-source. decompress the bz2 files starting with patches. First, run the root permission lsmod to check which modules have been loaded, and then find out if the patch file name contains a module name. If yes, check the system architecture and other information. You don't have to take a closer look at each file name. If you are an Acer notebook, the file name containing IBM asus has nothing to do with you. Similarly, if you are a 32-bit system, the patch with x86_64 ia64 ppc in the file name does not make sense to you. If you use amd cpu and chipset, you do not have to look at the patch with intel name. You are not sure whether the patch is required. You can click it to view the comment at the beginning of the file.

Remember, if you only have a rough understanding of your hardware, You can first do not play or play a few hardware patches that you think are necessary. If something goes wrong, follow the log prompts, search to see if a patch is required, and then recompile it with the patch.

The feature requires that some software must be patched to implement its own functions. In order to make these software run normally, it has to be patched, such as the Bootsplash patch mentioned below. If you do not know about this, you can wait for a problem and search again.

The psychological need is to have emotional dependence on some patches for various reasons. If you do not apply the patches, the users will be in bad mood. In order to avoid serious unpredictable consequences, appropriate patches should be installed to avoid such situations.

Common patch Systems
MM patch:

Http://kernel.org/patchtypes/mm.html

A series of patches compiled by Andrew Morton, the 2.6 maintainer, have many upgrades to kernel components and hardware compatibility patches. It is very important and commonly used.

AC patch:

Http://kerneltrap.org/forum/linux/kernel/2.6/ac

A set of patches maintained by Alan Cox of Redhat. It is generally used to add hardware support patches.

CK patch:

Http://members.optusnet.com.au/ckolivas/kernel/

A set of patches maintained by Con Kolivas. A large number of performance optimization patches are included, which are applicable to both desktop and server. If you want to speed up the system, you can choose to use some of the patches, all of which may cause a crash.

Common SUSE Patches
Apparmor patch-works with Novell Apparmor software as a unique security module for SUSE.

Bootsplash patch-animation when the system is started.

Flush-o-fat patch-add-o acceleration parameters to the hard drive written to the FAT format. Without this patch, the mobile hard drive in the FAT format may not be automatically mounted.

Patch sequence and Method
Sequence
Patch patching is performed sequentially. Generally, the incremental update patch provided by the official website is used first, followed by the patch required by the hardware, and then the patch required by the function. The priority of the psychological requirement patch is higher than that of all patches, or even higher than the kernel source code itself.

To use src. rpm, You need to incrementally upgrade the patch to the new version. You do not need to take this step because the source code of the original kernel is the latest.

Single patch file
A single patch file may have the following suffix. diff. patch or no suffix. It is essentially a plain text file and can be opened and modified in a text editor. The patch method is as follows:

# Cd/usr/src/linux-version # patch-p1-I/path/patch file name
For example, I manually download a file patch bootsplash for the pure kernel to enable the animation before the boot enters X and download the patch suitable for the latest kernel version, file is/home/truth/new/patches/bootsplash-2.6.18.diff

# Cd/usr/src/linux-2.6.18 # patch-p1-I ~ Truth/new/patches/bootsplash-2.6.18.diff
Patch in gz/bz2 format
Not all gz/bz2 files can be patched using the following method. Such files must only contain more than one single file patch and should not contain other impurities. Therefore, this method should first open the gz/bz2 compressed package to check whether the conditions are met. In essence, this patch method is to patch a single file in the ascending order of file names in the compressed package. Run the following command:

# Cd/usr/src/linux-version gz compressed package: # zcat path/file name .gz | patch-p1bz2 compressed package: # bzcat path/file name .bz2 | patch-p1
Here we use the official src. rpm source code as an example. The kernel incremental patch is the patches.kernel.org.tar.bz2 extracted from src. rpm in the/home/truth/new/patches/directory.

# Cd/usr/src/linux-2.6.16 # bzcat ~ Truth/new/patches/patches.kernel.org.tar.bz2 | patch-p1
Some patches in the compressed package have requirements on the path. Generally, they can be placed in the/usr/src/directory. For more information about patch commands, see info patch.
Related Article

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.