RedHatAS4 Kernel configuration change and re-Compilation

Source: Internet
Author: User
Tags rpmbuild
This article introduces RedHatAS4 Kernel configuration change and re-compilation-general Linux technology-Linux programming and kernel information. The following is a detailed description. I. kernel memory configuration check:

You can use the following method to check whether the kernel supports 64 GB memory at startup.

First, find out which kernel is used during startup

[Root @ study ~] # Cat/boot/grub. conf

...

Default = 0 (indicating that the first entry is started by default)

Timeout = 5

Splashimage = (hd0, 0)/grub/splash.xpm.gz

Hiddenmenu

Title Red Hat Enterprise Linux AS (2.6.9-34. ELsmp)

Root (hd0, 0)

Kernel/vmlinuz-2.6.9-34.ELsmp ro root =/dev/VolGroup00/LogVol00 rhgb quiet

Initrd/initrd-2.6.9-34.ELsmp.img

Title Red Hat Enterprise Linux AS-up (2.6.9-34.EL)

Root (hd0, 0)

Kernel/vmlinuz-2.6.9-34.EL ro root =/dev/VolGroup00/LogVol00 rhgb quiet

Initrd/initrd-2.6.9-34.EL.img


My kernel is vmlinuz-2.6.9-34.ELsmp

The corresponding kernel compilation file during installation is

/Boot/config-2.6.9-34.ELsmp


Check high memory support

[Root @ study ~] # More/boot/config-2.6.9-34.ELsmp | grep 4G

# CONFIG_X86_4G is not set

# CONFIG_X86_4G_VM_LAYOUT is not set

# CONFIG_HIGHMEM4G is not set

CONFIG_HIGHMEM64G = y indicates that 64 GB memory is selected during kernel compilation,


Only 4G Support is similar:

[Root @ study ~] # More/boot/config-2.6.9-34.EL | grep 4G

# CONFIG_X86_4G is not set

# CONFIG_X86_4G_VM_LAYOUT is not set

CONFIG_HIGHMEM4G = y

# CONFIG_HIGHMEM64G is not set


-----------------------

Ii. customized kernel:

-----------------------

If you want to change the kernel's support for high memory, you need to re-compile the kernel. There are two methods to customize the kernel

1) redhat is proprietary. An rpm kernel package can be obtained in the middle for installation or sharing with others.

2) It is used in all linux distributions and will not get the rpm package to generate your customized kernel from the original code.

Only the first type is described here.

Warning:

The customized kernel is out of service scope and support process. This may cause your system to lose the RedHat Support Service. At your own risk.



If you want to change the Kernel configuration of a redhat system that has been put into operation, follow the steps I mentioned to minimize the impact.


1. Check related Toolkit

[Root @ study ~] # System-config-packages

On the "add or delete software package" page that appears, select "development tools" and check its details,

Kernel-devel, kernel-smp-devel, kernel-hugemem-devel, they will generate the following folders:

[Root @ study ~] # Ls/usr/src/kernels/

2.6.9-34. EL-hugemem-i686 2.6.9-34. EL-i686 2.6.9-34. EL-smp-i686

Each folder corresponds to a kernel code tree (they are not complete code, but can be used to compile the corresponding kernel module,

But cannot be used to compile the real kernel ).


2. Prepare a complete source code Environment

Use the same software package (cat/etc/redhat-release) as your system version ).


If you have registered a Red Hat Network, you can download the installation source code using the following method:


# Up2date redhat-rpm-config rpm-build

# Up2date -- get-source kernel

# Rpm-ivh/var/spool/up2date/kernel *. src. rpm


Reference http://www.redhat.com/docs/manua... lease-notes/as-x86/


If you have not registered a Red Hat Network, you can only download and install it manually. (I guess this package can be found on the CD, but I cannot test the CD)

Ftp://ftp.redhat.com/pub/redhat/... el-2.6.9-34.src.rpm

Download a software package that is consistent with your system version.

# Rpm-ivh/mnt/kernel-2.6.9-34.src.rpm



# Cd/usr/src/redhat/SPECS/

# Cd/usr/src/redhat/SPECS

# Vi kernel-2.6.spec

The main changes are as follows:


Define buildsource 0 ------------ change this to 1 in row 8th,

This is why there is no source code package, because the source code package is not generated by default.

% Define buildhugemem 1 supports high memory

% Define buildsmp 1 supports multi-processor

% Define buildlargesmp 1 supports more processors


Requires: qt-devel, gtk2-devel readline-devel ncurses-devel

If X is not used in line 2, comment out this sentence so that the compiled package does not depend on some packages in X-window,

Because make xconfig can be used for Kernel configuration, X-window is relied on by default. If X-window is not installed, comment out it.


Save and exit.


# Touch/etc/beehive-root

This command is not required. If not, the final compiled package will be changed to kernel-*. *-root. rpm, with an additional root,

It is said that it is to mark the package compiler. If you touch this file, there will be no such problem. The name is the same as the official rpm.


# Rpmbuild-ba -- target = 'uname-M'./kernel-2.6.spec

Compile all the packages on the i686 platform (here the uname-m command will get the i686 result), so that all the packages described above will be generated,

Or change to rpmbuild-bb -- target = 'uname-M'./The kernel-2.6.spec to compile only non-src. rpm.

All packages are generated under/usr/src/redhat/RPMS/i686.

If you only need sourcecode and not all rpm packages, modify the following lines when modifying the spec file:

% Ifarch noarch

% Define builddoc 1

% Define buildsource 0 --------------- here 0 is changed to 1

Use rpmbuild-ba -- target = noarch./kernel-2.6.spec during compilation so that only sourcecode and doc packages are compiled,

It saves a lot of time.


3. Configure the kernel


To identify our customized kernel in the future, we can distinguish it from the existing kernel:


[Root @ study kernel-2.6.9] # cd/usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9/

[Root @ study linux-2.6.9] # vi Makefile


Change EXTRAVERSION to the following format:

EXTRAVERSION =-custom-2.6.9-34



Because my/boot/config-2.6.9-34.EL kernel does not support 64 GB memory, I want to "clone" a new and support 64 GB memory.

[Root @ study linux-2.6.9] # diff. config/boot/config-2.6.9-34.EL compare the two configuration files,

Generally, there is no output, that is, no difference. If there is a difference:

[Root @ study linux-2.6.9] # cp/boot/config-2.6.9-34.EL. config

Cp: overwrite '. config '? Y

Our purpose is to modify the memory configuration only on the basis of the original. This. config file determines the options for compiling the kernel.

We do not recommend that you modify. config directly, but use the following method:

[Root @ study: linux-2.6.9] # make menuconfig

Select Processor type and features --->

Select High Memory Support (4 GB) --->

() Off

() 4 GB

(X) 64 GB

Exit, exit, and then exit. When the following information appears, select yes.

Do you wish to save your new kernel configuration?


4. Compile and install the kernel


There are two options. The results are consistent. Choose either of them.


1) at this time, you can create an rpm

[Root @ study linux-2.6.9] # make rpm

This kernel rpm package is installed

[Root @ study linux-2.6.9] # RPMS/i386/kernel-2.6.9custom2.6.934-2.i386.rpm rpm-ivh/usr/src/redhat/RPMS/


We can see that our new Kernel File vmlinuz-2.6.9-custom-2.6.9-34 is missing under/boot.

The 2.6.9-custom-2.6.9-34 folder is added under/lib/modules, which contains all modules of the new kernel.


Create a memory disk for our new kernel to ensure that the new kernel can be started

[Root @ study linux-2.6.9] # mkinitrd/boot/initrd-2.6.9-custom-2.6.9-34.img 2.6.9-custom-2.6.9-34


Add a new Kernel configuration in the configuration file of the boot loader grub.

[Root @ study: linux-2.6.9] # vi/boot/grub/conf


Default = 2 because the configuration segment of my new kernel is 3rd bits, the new kernel is used as the default startup Item.

...

Title Red Hat Enterprise Linux AS (2.6.9-34 custom)

Root (hd0, 0)

Kernel/vmlinuz-2.6.9-custom-2.6.9-34 ro root =/dev/VolGroup00/LogVol00 rhgb quiet

Initrd/initrd-2.6.9-custom-2.6.9-34.img


[Root @ study linux-2.6.9] # make

[Root @ study linux-2.6.9] # make modules_install

[Root @ study linux-2.6.9] # make install

The new kernel, initrd, and system. map are automatically copied to the/boot directory, and the new kernel is automatically added to the grub. conf startup list.


After completing one of the above two steps


The customized kernel is used when the system restarts.

[Root @ study linux-2.6.9] # reboot


Check the running status of the system and various services. If any error occurs, you can change the default value of/boot/grub. conf and select the original configuration segment,

After the restart, the original kernel is restored.
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.