Compile the Linux3.0.1 kernel in RHEL6

Source: Internet
Author: User
The following describes how to compile LinuxKernel3.0.1 in rhel6. Because the kernel compilation process is similar, the following process is also applicable to other releases in theory (for example, Ubuntu11.04 in the stool series. Below I will also note the similarities and differences of using the stool series for compilation ), if there is a problem with the compiled kernel, you may not be able to start the computer using the new compiled kernel, so you need to keep the currently used kernel. 1. Download and decompress the source code of LinuxKernel3.0.1.

The following describes how to compile Linux Kernel 3.0.1 in rhel6. Because the kernel compilation process is similar, the following process is also applicable to other releases in theory (for example, Ubuntu 11.04 in the stool series, I will also note the similarities and differences of using the stool series for compilation ), if there is a problem with the compiled kernel, you may not be able to start the computer using the new compiled kernel, so you need to keep the currently used kernel.

1. Download and decompress the Linux Kernel 3.0.1 source code
Go to the official http://kernel.org/download, get the linux-3.0.1.tar.bz2 file, move it to any folder where you have read and write permissions, run the following command to decompress and enter the decompressed Folder:
$ Tar jxvf linux-3.0.1.tar.bz2
$ Linux-3.0.1 cd

2. Configure kernel compilation Parameters
First install the ncurses tool, which is dependent on the character edition Configuration tool:
$ Sudo yum install ncurses-devel # (Red Hat series environment)
$ Apt-get install libncurses5 libncurses5-dev # (stool series environment)

I have already manually configured sudoers on the local machine, so how can I prompt that the current user is not sudoer Please configure sudoers or available root (I have not tested it)
Add the user to sudo for execution permission:
1. chmod u + w/etc/sudoers
2. vim/etc/sudoers
3. Add [user] ALL = (ALL) ALL ([user] as the authorized user) under root ALL = (ALL) ALL)
4. chmod 440/etc/sudoers

The new version of the Configuration tool will automatically find the configuration information of the current system environment (that is, the file starting with config-XXX in/boot), so you can directly run the character version of the Configuration tool:
$ Make menuconfig

There are many configuration options here. If you are trying, you don't have to worry about it. Select "Save" under the menu and exit. The configuration tool will generate a ". config file.

3. Start Compilation
$ Make

The compilation process ranges from 10 minutes to 1 or 2 hours, depending on the speed at which your computer runs. If the CPU is 4-core, you can add the "-j4" parameter after the make command to make the compilation program use 4-core compilation at the same time, so that the compilation time can be reduced by times.

If the compilation process is accidentally interrupted and you want to re-compile, You need to execute the following command to clear the compilation site and then compile it:
$ Make mrproper

(This is a long wait process)

4. Install the compiled modules and Kernel
After the kernel is compiled, run the following command to install modules:
$ Sudo make modules_install

The preceding Command copies the compiled modules to the "/lib/modules/3.0.1" folder, where "3.0.1" is the kernel version, you will see the modules of other kernel versions in the "/lib/modules" folder, including the current system environment. This is a very important folder. Do not manually delete these folders.

Then install the compiled kernel image file:
$ Sudo make install

The above Command copies the "arch/x86/boot/bzImage" file in the compiling folder to "/boot", and also copies init and System. the map file will eventually contain the following three files in "/boot:

/Boot/initramfs-3.0.1.img
/Boot/System. map-3.0.1
/Boot/vmlinuz-3.0.1
Now, restart the machine and select the kernel 3.0.1 to start Linux.

But is there a saying on the Internet that the initrd. img file (initial ram disk file) is missing during installation )? Run the following command to create one:
$ Sudo mkinitrd initramfs-3.0.1.img 3.0.1 # (Red Hat series environment)
$ Sudo mkinitramfs 3.0.1-o/boot/initrd. img-3.0.1 # (stool series environment)

5. Modify the GRUB boot menu and add a project to start with the new kernel.
You can use the automatic generation tool of GRUB2 to complete this step.
$ Sudo grub2-mkconfig # (Red Hat series environment)
$ Sudo update-grub2 # (stool series environment)

If you do not want to modify the GRUB boot menu (not sure about the new kernel), you can manually specify the new kernel when starting Linux as follows:
Restart the computer, Press ESC on the GRUB menu interface (if you do not see it, then restart the computer), press "c" to enter the command mode, and set the partition of the Startup File first, suppose "/boot" is in the first partition of the first hard disk. If it is in another partition, change the number "1" below to "2, 3, 5, 6, 7 ......" And so on:
Set root = (hd0, 1)

Specify the kernel image and virtual ram disk file location:
Linux/boot/vmlinuz-3.0.1 root =/dev/sda1
Initrd/boot/initrd. img-3.0.1

Note: In GRUB command mode, you can press the "TAB" key to automatically complete the task. Do not enter one word or more. Finally, enter "boot" to start.

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.