系统环境:
$ uname -rs
Linux 3.10.0-1160.45.1.el7.x86_64
载入公钥并安装 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
Loaded plugins: fastestmirror, langpacks
elrepo-release-7.el7.elrepo.noarch.rpm | 8.6 kB 00:00:00
Examining /var/tmp/yum-root-5iUPAM/elrepo-release-7.el7.elrepo.noarch.rpm: elrepo-release-7.0-5.el7.elrepo.noarch
Marking /var/tmp/yum-root-5iUPAM/elrepo-release-7.el7.elrepo.noarch.rpm to be installed
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package elrepo-release.noarch 0:7.0-5.el7.elrepo will be installed
--> Finished Dependency Resolution
base/7/x86_64 | 3.6 kB 00:00:00
docker-ce-stable/x86_64 | 3.5 kB 00:00:00
docker-ce-stable/x86_64/primary_db | 70 kB 00:00:00
epel/x86_64 | 4.7 kB 00:00:00
epel/x86_64/updateinfo | 1.0 MB 00:00:00
epel/x86_64/primary_db | 7.0 MB 00:00:01
extras/7/x86_64 | 2.9 kB 00:00:00
packages-microsoft-com-prod | 3.0 kB 00:00:00
packages-microsoft-com-prod/primary_db | 505 kB 00:00:00
updates/7/x86_64 | 2.9 kB 00:00:00
updates/7/x86_64/primary_db | 13 MB 00:00:02
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
elrepo-release noarch 7.0-5.el7.elrepo /elrepo-release-7.el7.elrepo.noarch 5.0 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1 Package
Total size: 5.0 k
Installed size: 5.0 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : elrepo-release-7.0-5.el7.elrepo.noarch 1/1
Verifying : elrepo-release-7.0-5.el7.elrepo.noarch 1/1
Installed:
elrepo-release.noarch 0:7.0-5.el7.elrepo
Complete!
查询出可以使用的 kernel 包版本:
$ yum list available --disablerepo=* --enablerepo=elrepo-kernel
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* elrepo-kernel: hkg.mirror.rackspace.com
elrepo-kernel | 3.0 kB 00:00:00
elrepo-kernel/primary_db | 2.0 MB 00:00:01
Available Packages
kernel-lt.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.171-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
perf.x86_64 5.16.0-1.el7.elrepo elrepo-kernel
python-perf.x86_64
lt表示长期维护版,ml表示最新稳定版。
安装指定的 kernel 版本:
$ yum install -y kernel-lt-5.4.171-1.el7.elrepo --enablerepo=elrepo-kernel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* elrepo: hkg.mirror.rackspace.com
* elrepo-kernel: hkg.mirror.rackspace.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
elrepo | 3.0 kB 00:00:00
elrepo/primary_db | 545 kB 00:00:00
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package kernel-lt.x86_64 0:5.4.171-1.el7.elrepo will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
kernel-lt x86_64 5.4.171-1.el7.elrepo elrepo-kernel 50 M
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1 Package
Total download size: 50 M
Installed size: 228 M
Downloading packages:
kernel-lt-5.4.171-1.el7.elrepo.x86_64.rpm | 50 MB 00:00:08
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : kernel-lt-5.4.171-1.el7.elrepo.x86_64 1/1
Verifying : kernel-lt-5.4.171-1.el7.elrepo.x86_64 1/1
Installed:
kernel-lt.x86_64 0:5.4.171-1.el7.elrepo
Complete!
这里我选择安装5.4的版本。
设置开启系统启动时使用的内核版本:
## 查看系统可用内核
$ 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.171-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux 7 Rescue d7566b7634d99969d46b74186b897f86 (3.10.0-1160.45.1.el7.x86_64)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux (3.10.0-1160.45.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux 7 Rescue d4387c178451a59914edf1c69e6972e6 (3.10.0-1127.el7.x86_64)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
menuentry 'CentOS Linux (0-rescue-4314bdb98c294da598ef91c169d55769) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-4314bdb98c294da598ef91c169d55769-advanced-0bb4bfa4-b315-43ca-a789-2b43e726c10c' {
## 设置开机从新内核启动
$ grub2-set-default "CentOS Linux (5.4.171-1.el7.elrepo.x86_64) 7 (Core)"
## 查看内核启动项
$ grub2-editenv list
saved_entry=CentOS Linux (5.4.171-1.el7.elrepo.x86_64) 7 (Core)
## 重启系统
$ reboot
## 启动完成查看内核版本是否更新:
$ uname -rs
Linux 5.4.171-1.el7.elrepo.x86_64
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://zuozewei.blog.csdn.net/article/details/122488898
内容来源于网络,如有侵权,请联系作者删除!