Get the kernel source code
mkdir /kernel && cd /kernel
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.2.11.tar.gz
tar xf linux-5.2.11.tar.xz
[root@localhost kernel]# ls -l
total 104556
drwxrwxr-x 27 root root 4096 Mar 17 12:02 linux-5.2.11
-rw-r--r-- 1 root root 107057392 Mar 17 09:28 linux-5.2.11.tar.xz
View the current kernel version of the system
[root@localhost kernel]# uname -r
3.10.0-1127.el7.x86_64
Download the software dependencies required to compile the source code
yum -y groupinstall "development tools"
yum -y install openssh-devel elfutils-libelf-devel bc
yum install -y gcc、gcc-c++、bc、patch、 ncurese-devel
Production .config file
make menuconfig
General setup —> Local version - append to kernel release
Modify the kernel name to: 5.2.11-001.el7.x86_64
Compile the source code
make -jN
N indicates the number of CPU cores used
Compile and install the module
make modules_install
Install kernel core files
make install
Set to boot the kernel by default
cat /boot/grub2/grub.cfg | grep menuentry
grub2-set-default 'CentOS Linux (5.2.115.2.11-001.el7.x86_64) 7 (Core)'
grub2-editenv list
Restart server
reboot
[root@localhost kernel]# uname -r
5.2.115.2.11-001.el7.x86_64