Compile the Linux kernel under centos5.1-general Linux technology-Linux programming and kernel information. The following is a detailed description. The Linux kernel compilation method, the original kernel version is Linux-2.6.18.8, the new kernel version is Linux-2.6.26, other kernel version compilation method is similar.
1. Preparations
First, you can download the kernel at http://www.kernel.org.
After the kernel is compressed into the package (set as linux-2.6.26.tar.gz), copy the package to the/usr/src directory, go to the/usr/src directory, and unzip the package. The command is as follows (assume that the current directory is the directory of the kernel pack)
Ii. Generate the configuration file required for compilation
First, enter the decompressed kernel file. The command is as follows:
Cd/usr/src/linux-2.6.26
Enter make menuconfig to bring up the Kernel configuration interface. On this interface, you can generate the configuration file required for compiling the kernel in a graphical way. This is very convenient!
At this point, all preparations are completed, and the actual compilation phase is entered below.
Start Compilation
It mainly includes the following steps.
1. Enter make dep, which means that the system can pre-process the kernel code.
2. Enter make bzlmage and start compilation. It may take a long time to complete the process, depending on the machine performance.
3. Enter make modules to start compiling the module.
4. Enter make modules_install to start the installation module.
5. Enter make install to install the compiled kernel.
In general, the above process will not encounter any exceptions
Iv. Compilation completed
This file is used in the compiled kernel.
/Usr/src/linux-2.6.26/arch/i386/boot/bzlmage
5. Modify the Startup Program configuration and start the new kernel.
After compilation, you can view the boot loader configuration file. For different boot programs (LILO and GRUB), the path of the configuration file is different.
For LILO, the path is/etc/lilo. conf.
For GRUB, the path is/boot/grub/menu. lst.
The system is GRUB boot, So enter/boot/grub/menu. lst. The command is as follows:
Cd/boot/grub
Vi menu. lst
The startup Item is automatically configured for you in centos.
After restarting, you can see that boot loader can load two versions of the kernel. In this file, you can easily modify some information, such as the default loaded kernel version, the duration of the boot program, the name of the kernel on the boot interface, and so on.
Restart the machine and you can see that there are two types of kernel options on the boot interface. We choose the linux-6.26, that is, the compiled kernel, after normal access can be through the/proc/version file to determine the current startup kernel version is 2.6.26, the command is as follows
Cd/proc
Vi version
The kernel is compiled successfully!
Note: At the beginning, we can do this on a virtual machine, such as VMware (recommended) or KVM, to avoid system crashes.
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