安装kernel
https://linoxide.com/linux-how-to/upgrade-linux-kernel-stable-3-18-4-centos/
设置默认启动
https://blog.csdn.net/ykun089/article/details/106347681/
装最新的kernel
1. Downloading and Installing ELRepo
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
2.Updating Kernel to version 3.18.4
yum --enablerepo=elrepo-kernel install kernel-ml
编译特定版本的kernel
1.Installing the Dependencies
yum install gcc ncurses ncurses-devel
yum update
2. Downloading the package
# cd /tmp/
# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.18.4.tar.xz
3.Extracting the package
# tar -xf linux-3.18.4.tar.xz -C /usr/src/
# cd /usr/src/linux-3.18.4/
4. Configuring or use the old configuration directly
make menuconfig
or
make oldconfig
5.Compiling
make
6. Installing into the system
make modules_install install
7.Verifying Kernel
uname -r
8. 设置默认启动该内核
a.查看当前默认启动内核
grub2-editenv list
b. 罗列所有内核
cat /boot/grub2/grub.cfg | grep menuentry
c. 设置默认启动内核
grub2-set-default 'CentOS Linux (3.10.107) 7 (Core)'
d.确认改动的结果
grub2-editenv list
e. 重启系统
reboot
9. tips
有的时候我们需要适用kernel内核的模块,比如powercap,然而并不是所有的kernel都有这个模块,比如3.10和3.13有,但是5.0没有。所以,当我们对模块有特定需求时,在升级kernel前要看一下kernel的源码,确认有我们想要的模块时,才能升级。