CentOS7 1810 升级内核

查看当前内核版本

# uname -a
Linux localhost.localdomain 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

在线升级内核

1、导入公钥
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

2、安装elrepo库
# yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

3、 查看内核包版本
kernel-lt:longterm的缩写:长期维护版
kernel-ml:mainline的缩写:最新稳定版
# yum list available --disablerepo=* --enablerepo=elrepo-kernel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
Available Packages
kernel-lt.x86_64                    5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-devel.x86_64              5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-doc.noarch                5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-headers.x86_64            5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-tools.x86_64              5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-tools-libs.x86_64         5.4.159-1.el7.elrepo       elrepo-kernel
kernel-lt-tools-libs-devel.x86_64   5.4.159-1.el7.elrepo       elrepo-kernel
kernel-ml.x86_64                    5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-devel.x86_64              5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-doc.noarch                5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-headers.x86_64            5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-tools.x86_64              5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-tools-libs.x86_64         5.15.2-1.el7.elrepo        elrepo-kernel
kernel-ml-tools-libs-devel.x86_64   5.15.2-1.el7.elrepo        elrepo-kernel
perf.x86_64                         5.15.2-1.el7.elrepo        elrepo-kernel
python-perf.x86_64                  5.15.2-1.el7.elrepo        elrepo-kernel

4、 卸载旧版内核并安装最新稳定版内核
# for i in `sudo rpm -qa | grep kernel`;do sudo rpm -e $i --nodeps;done
# yum install -y kernel-ml-5.15.1-1.el7.elrepo.x86_64 --enablerepo=elrepo-kernel

5、查看当前可用内核
# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (5.15.1-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (0-rescue-e74676bd84244714b5425cf97bd6c162) 7 (Core)

6、设置启用内核
# grub2-set-default 0

7、修改配置文件
# sed -i 's/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/g' /etc/default/grub

8、产生启动配置
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.1-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.15.1-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-e74676bd84244714b5425cf97bd6c162
Found initrd image: /boot/initramfs-0-rescue-e74676bd84244714b5425cf97bd6c162.img
done

9、重启
# reboot

10、查看内核版本
# uname -r
5.15.1-1.el7.elrepo.x86_64

离线升级内核

1、下载离线包(rpm)
https://elrepo.org/linux/kernel/el7/x86_64/RPMS/
下载下图中的红色选中部分

ffac5c83b4f78d470cc95f3e0a35666.png

2、 安装方式

采用rpm命令安装即可
rpm -ivh /path/*.rpm

3、 说明

安装完成后,后续操作同在线安装中4~10的步骤

你可能感兴趣的:(CentOS7 1810 升级内核)