centos6.2 Kernel Custom Compilation

Source: Internet
Author: User
Tags config rpmbuild
1 centos6.2 Kernel compilation customization Skills detailed

After learning the third chapter on the centos5.2 platform for the kernel customization compiled, we take centos6.2 as an example, the complete walk again, the basic steps are the same, the details may be slightly different, we can continue in the virtual machine fast combat, the kernel custom compiler is skilled operation, in the follow-up of our core combat learning to assist me Kernel code debugging and kernel function development. 1.1 Install kernel source 1.1.1 Download the official kernel source code

You can download the kernel source package from the official path below, or we will copy it to you in the classroom for practical practice.

CENTOS62 Source Path:

http://vault.centos.org/6.2/os/Source/SPackages/kernel-2.6.32-220.el6.src.rpm

1.1.2 Install the official kernel source code

First we configure the Rpmmacros macro definition file, which is used to guide the rpmbuild command, the command and RPM we put in the 5th chapter for detailed introduction, now we need to understand the basic steps and skilled use:

echo "%_topdir/usr/src/redhat" > ~/.rpmmacros

Then install the source src.rpm package:

RPM-IHV kernel-2.6.32-220.el6.src.rpm

Cd/usr/src/redhat/specs

RPMBUILD–BP--target x86_64 Kernel.spec

The kernel source can be installed into the/usr/src/redhat/directory.

F ensure that the remaining space is at least 10G, or the remaining space will be reported at compile time. 1.2 kernel patch 1.2.1 A real-world patch to the kernel

Take the SCST and ISCSI-SCST module as an example to introduce the centos6.2 kernel patch process, you can not learn SCST knowledge, here is just two practical modules as an example, practical practice how to patch the kernel on the centos6.2. These two kernel patches can be found in the following links or in the classroom we will also copy to you for Live practice:

SCST Module official website path:

https://scst.svn.sourceforge.net/svnroot/scst/trunk/;

The Patch path is:

Scst/kernel/rhel/scst_exec_req_fifo-2.6.32.patch;

iscsi-scst/kernel/patches/rhel/put_page_callback-2.6.32-220.patch 1.2.2 Verifying the correctness of patches

Go to Catalog

/usr/src/redhat/build/kernel-2.6.32-220.el6/linux-2.6.32-220.el6.x86_64 can see centos6.2 source installed under this path.

1. Modify SCST and ISCSI-SCST patches, the int res defined in all functions, modify to intres=0; (no modification, error is reported when compiling the kernel)

2. Enter the/usr/src/redhat/build source directory to run the command:

Patch-p1 < Scst_exec_req_fifo-2.6.32.patch;

Patch-p1 < Put_page_callback-2.6.32-220.patch

When you hit patch, if you have a problem, it's generally the place in the patch that needs to be modified and does not match the location labeled in the Patch:

1. If the prompt success, do not need to change;

2. If prompted failure, the patch file is wrong and you need to download the correct patch. 1.3 Configuring the kernel 1.3.1 Configuration file

Centos6.2 configuration files (. config) are all generated from files that begin with config-*, which have corresponding config-* for different architectures, for example x86 architecture, if the contents of the file have the same kernel configuration information, the precedence order is:

1. Config-x86_64-nodebug-rhel, Config-x86_64-nodebug

2. Config-x86_64-generic-rhel, Config-x86_64-generic

3. Config-nodebug-rhel, Config-nodebug

In order to configure their own kernel we need to add their own configuration in the original config-*, when configured, such as a higher priority profile an option has been selected then the low priority config-* file does not need to be changed. 1.3.2 Finding kernel modifications

Then execute: Make Menuconfig, we take the custom XFS file system as an example of the actual combat.

N Open xfs option, compile into kernel module

U filesystems--->

U <m>xfsfilesystem Support

u [*] XFS Quota Support

u [*] XFS POSIX ACL Support

u [*] XFS Realtime subvolume Support

N Open SCST Network-related parameters (this section only appears if you hit SCST and ISCSI-SCST patches)

U networkingsupport--à

L Networkingoptions-à

n [*]tcp/ipzero-copy Transfer completion notification

When configured, you can press the H key to see a detailed description of each kernel option, including the name of each option, dependencies, and so on. Records the names of several options modified and their adjacent option names (used to locate their specific location in the config file).

1. XFS file System Related: Config_xfs_rt, nearby options:

Config_xfs_fs=m

2. SCST and ISCSI-SCST Related:

Config_tcp_zero_copy_transfer_completion_notification, near the options:

Config_inet=y

So far, we can execute make&& make modules && makes Modules_install && make install to complete the kernel compilation, But we continue to introduce how to make the kernel RPM package, and finally put our kernel in the RPM package so that we can publish our own created kernel. The introduction of specific RPM we put in the 5th chapter detailed introduction, we continue to go down. 1.3.3 Modifying and saving configuration files in the kernel customization Process

1. Enter the directory:

/usr/src/redhat/build/kernel-2.6.32-220.el6/linux-2.6.32-220.el6.x86_64 Copy the configuration file and return to the upper directory, execute the following command:

CP config-*. /. && CD.

2. Search all config-* files that contain config_xfs_fs:

grep config_xfs_fsconfig-*,

The result contains the following files:

A) config-generic

b) Config-i686-rhel

c) Config-powerpc-generic-rhel

D) Config-s390x-rhel

In a x86_64 environment, you only need to modify the file Config-generic to

#CONFIG_XFS_RT is not set can be modified to config_xfs_rt=y.

3. Search all config-* files that contain config_inet:

Grep-r config_inet config-*

The result contains the following files:

A) config-generic

b) config-s390x-kdump

Only need to modify the file Config-generic, add config_tcp_zero_copy_transfer_completion_notification=y below the config_inet=y line.

4. Save the final modified configuration file Config-generic, execute the following command:

CP config-generic/usr/src/redhat/sources/

Overwrite the Config-generic file under the sources directory. 1.4 Modify spec file and make RPM package 1.4.1 Spec file modification

Go to directory/usr/src/redhat/specs, search for Patch999999 in file Kernel.spec, and add the following:

Patch999998:put_page_callback-2.6.32-220.patch

Patch999997:scst_exec_req_fifo-2.6.32.patch

Search for Applyoptionalpatchlinux-kernel-test.patch, add after Applyoptionalpatch Linux-kernel-test.patch

Applyoptionalpatchscst_exec_req_fifo-2.6.32.patch

Applyoptionalpatchput_page_callback-2.6.32-220.patch

Search for Buildid and add the following:%define Buildid. Talk,

To modify this value, you can change the name of the generated RPM package as follows (the red part is Buildid):

Modified before: kernel-2.6.32-220.el6.x86_64.rpm

Modified: kernel-2.6.32-220.el6.talk.x86_64.rpm 1.4.2 Generate RPM package

Copy the Scst_exec_req_fifo-2.6.32.patch/put_page_callback-2.6.32-220.patch to the/usr/src/redhat/sources directory;

To enter the directory/usr/src/redhat/specs, execute the following command:

Rpmbuild-ba--with baseonly--with firmware--without kabichk--target= ' uname-m ' Kernel.spec

This command will eventually generate: source packages, RPM packages (including debug packages, which can be used for kernel code debugging), and can be viewed separately into/usr/src/redhat/rpms and/usr/src/redhat/srpms.

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.