How to compile and install a new version of the kernel from source code under CentOS?
At work, many times due to the need to use new technical solutions, a newer version of the kernel is needed to support new functions, and the kernel version that comes with the CentOS system is generally older, so we The system kernel needs to be upgraded and a new version of the kernel needs to be installed. Here, taking the CentOS 7 system as an example, the process of compiling and installing the latest version of the kernel is summarized as follows:
1. Download the latest stable version of the kernel source code package to/usr/local/ src
and extract it to the current directory
##2. Unzip the kernel source package
#3. Copy the existing version of the kernel compilation config configuration file from the /boot directory to the new kernel source code decompression directory and rename it For the hidden file of .config
[root@localhost src]# cd linux-5.2.11 [root@localhost linux-5.2.11]# cp /boot/config-3.10.0-957.el7.x86_64 ./.config
4. Install dependency packages
Install development tool package group[root@localhost linux-5.2.11]# yum -y groupinstall "development tools"
[root@localhost linux-5.2.11]# yum -y install ncurses-devel
5. Run make menuconfig and open the compilation options menu window of the text interface. You can adjust the module compilation options loaded by the kernel, such as modifying the compiled kernel name and adding new modules that were missing from the previous system. wait.
Modify the kernel name:General setup --->local version -append to kernel release
5.2.11-001.el7.x86_64
File systems --->DOS/FAT/NT Filesystems --->NTFS file system support
6. Compile the kernel
[root@localhost linux-5.2.11]# make -j 4 #根据CPU核数开启多线程编译以加快编译速度
[root@localhost linux-5.2.11]# yum -y install openssh-devel elfutils-libelf-devel bc
7. Compile and install the module
After the compilation is completed, execute make modules_install to install the kernel module[root@localhost linux-5.2.11]# make modules_install
8. Install the kernel core file
[root@localhost linux-5.2.11]# make install
grub2-set-default 0 #0表示 /boot/grub2/grub.cfg 文件中排在第一位的 menuentry 段
[root@localhost ~]# uname -r 5.2.11-001.el7.x86_64
The above is the detailed content of How to compile and install a new version of the kernel from source code under CentOS. For more information, please follow other related articles on the PHP Chinese website!