获取内核源码
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
查看系统当前内核版本
[root@localhost kernel]# uname -r
3.10.0-1127.el7.x86_64
下载编译源码所需软件依赖
yum -y groupinstall "development tools"
yum -y install openssh-devel elfutils-libelf-devel bc
yum install -y gcc、gcc-c++、bc、patch、 ncurese-devel
生产.config文件
make menuconfig
General setup —> Local version - append to kernel release
修改内核名称为:5.2.11-001.el7.x86_64
编译源码
make -jN
N表示使用CPU核数
编译安装模块
make modules_install
安装内核核心文件
make install
设置为默认启动内核
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
重启服务器
reboot
[root@localhost kernel]# uname -r
5.2.115.2.11-001.el7.x86_64