First, Background introduction
Compile the kernel although in the actual work of the odds, but as a Linux operator, or to compile the kernel have a preliminary understanding of the following to introduce the method of compiling the kernel
Second, the Operation procedure
1. Check the development environment
Take CentOS6 as an example, confirming that the two package groups for server Platform development and development tools are installed.
Yum Grouplist | grep "Development"
2. Download the kernel source code
For example, the 3.10.105 version is downloaded to the root user's home directory and extracted to the specified directory, while creating a soft connection (the purpose of creating a soft connection is to change the soft connection point directly when the kernel is replaced later)
TAR-XF linux-3.10.105.tar.xz-c/usr/src/
LN-SV linux-3.10.105 Linux
3. Prepare the kernel template
The kernel is actually the kernel function is turned on or off, similar to the compilation and installation of the source code program./config--APR ... , just as the kernel has too many options, using a template can significantly reduce the time you choose. CentOS6 has already prepared a kernel template in the/boot/directory named config-$ (uname-r) file, copy it to the kernel source directory
Cd/usr/src/linux
cp/boot/config-2.6.32-642.el6.i686. config
4. Select the features enabled by the kernel
Make Manuconfig
Note : Any compile operation can only be done under the kernel source directory, that is, under the/usr/src/linux directory, use make to help to see more information, choose to quit and save
5. Compiling the kernel
MAKE-J #
To compile, #表示同时展开的作业数, recommendations and CPU cores are consistent,make is to compile the. config file, if the. config file is compiled after the completion of the missing or want to add a few features can be in the kernel source directory for some functions, a specific module of the compilation:
Cd/usr/src/linux
Make dir/compiles only the relevant code in the directory (some features)
Make Dir/file.ko only compiles a specific module
6. Installing the module
Make Modules_install recommends installing the modules before installing the compiled kernel to avoid missing the relevant modules
7. Install the kernel
Make install
Install the kernel, which will create a new kernel and INITRAMFS in the/boot directory when this step is completed.
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/91/43/wKiom1j0yAqByjf-AABDdVVrmzw746.png "title=" 1.png "Style=" Float:none; "alt=" Wkiom1j0yaqbyjf-aabddvvrmzw746.png "/>
The configuration information of the new kernel is also added to the grub.conf file in the Grub directory, but the old kernel is used by default
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/91/41/wKioL1j0yArAueEMAAB9RaBGrpk604.png "title=" 2.png "Style=" Float:none; "alt=" Wkiol1j0yaraueemaab9rabgrpk604.png "/>
Restart the operating system, and you will see that the new kernel is ready to use
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/91/41/wKioL1j0yAuDRbYJAAAmaoLGuC8888.png "title=" 3.png "Style=" Float:none; "alt=" Wkiol1j0yaudrbyjaaamaolguc8888.png "/>
Iii. Additional Information
Use of the 1.screen command
The wait time for the make command at compile time is too long, and if the terminal is disconnected from the server at this point (SSH interrupts), then the command initiated by SSH will also terminate, in order to avoid this situation, it is recommended to use the screen command, the screen command common options:
Screen #打开一个监视器
After Crtl+a release the keyboard and press the D key #暂时退出screen界面
Screen-ls #查看当前所有的screen界面
Screen-r < screen number > #返回指定屏幕号的screen界面
Exit #关闭screen界面
2. Cross-compiling the kernel
if the target platform of the compilation is not the same as the current platform, the kernel that is compiled directly on the current platform will not run on the specified platform, it will need to be cross-compiled and compiled using: Make Arch=arch_name, to get help with a specific target platform Make arch=arch_name Help
This article from "Rabbit-like rabbit sen Broken" blog, please be sure to keep this source http://arkling.blog.51cto.com/2844506/1916812
Linux kernel compilation