Centos7 升级内核
$ uname -rs
Linux 3.10.0-1160.45.1.el7.x86_64
2、安装 ELRepo
# 载入公钥
$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# 安装 ELRepo 最新版本
$ yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
3、安装最新的内核版本
查询可使用的 Kernel 包版本:
lt 表示长期维护版
ml 表示最新稳定版
$ yum list available --disablerepo=* --enablerepo=elrepo-kernel
Loaded plugins: fastestmirror
elrepo-kernel | 3.0 kB 00:00:00
elrepo-kernel/primary_db | 3.1 MB 00:01:45
Determining fastest mirrors
* elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
Available Packages
kernel-lt.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 6.4.1-1.el7.elrepo elrepo-kernel
perf.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.4.249-1.el7.elrepo elrepo-kernel
安装指定的 Kernel 版本:
$ yum install -y kernel-lt-5.4.249-1.el7.elrepo --enablerepo=elrepo-kernel
设置指定的 Kernel 版本:
# 查看系统可用的内核
$ cat /boot/grub2/grub.cfg | grep menuentry
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (5.4.249-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.26.2.el7.x86_64-advanced-59d9ca7b-4f39-4c0c-9334-c56c182076b5' {
menuentry 'CentOS Linux (3.10.0-514.26.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.26.2.el7.x86_64-advanced-59d9ca7b-4f39-4c0c-9334-c56c182076b5' {
menuentry 'CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-59d9ca7b-4f39-4c0c-9334-c56c182076b5' {
menuentry 'CentOS Linux (0-rescue-963c2c41b08343f7b063dddac6b2e486) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-963c2c41b08343f7b063dddac6b2e486-advanced-59d9ca7b-4f39-4c0c-9334-c56c182076b5' {
# 设置开机新内核启动
$ grub2-set-default "CentOS Linux (5.4.249-1.el7.elrepo.x86_64) 7 (Core)"
# 查看当前内核启动项
$ grub2-editenv list
saved_entry=CentOS Linux (5.4.249-1.el7.elrepo.x86_64) 7 (Core)
重启系统并验证 Kernel 版本:
# 重启系统
$ reboot
# 启动完成查看内核版本是否更新
$ uname -rs
Linux 5.4.249-1.el7.elrepo.x86_64