OS:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
download kernel repo
[root@localhost ~]# yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm -y
check repo
[root@localhost ~]# yum repolist all | grep elrepo
* elrepo: mirrors.tuna.tsinghua.edu.cn
elrepo ELRepo.org Community Enterprise Linu enabled: 133
elrepo-extras ELRepo.org Community Enterprise Linu disabled
elrepo-kernel ELRepo.org Community Enterprise Linu disabled
elrepo-testing ELRepo.org Community Enterprise Linu disabled
enable kernel repo
[root@localhost ~]# vim /etc/yum.repos.d/elrepo.repo
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=1 #将此处的0改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
列出仓库中关于kernel的包
[root@localhost ~]# yum list *kernel*
Installed Packages
kernel.x86_64 3.10.0-327.el7 @anaconda
kernel-debug-devel.x86_64 3.10.0-1062.9.1.el7 @updates
kernel-headers.x86_64 3.10.0-1062.9.1.el7 @updates
kernel-tools.x86_64 3.10.0-327.el7 @anaconda
kernel-tools-libs.x86_64 3.10.0-327.el7 @anaconda
Available Packages
abrt-addon-kerneloops.x86_64 2.1.11-60.el7.centos base
kernel.x86_64 3.10.0-1160.31.1.el7 updates
kernel-abi-whitelists.noarch 3.10.0-1160.31.1.el7 updates
kernel-debug.x86_64 3.10.0-1160.31.1.el7 updates
kernel-debug-devel.x86_64 3.10.0-1160.31.1.el7 updates
kernel-devel.x86_64 3.10.0-1160.31.1.el7 updates
kernel-doc.noarch 3.10.0-1160.31.1.el7 updates
kernel-headers.x86_64 3.10.0-1160.31.1.el7 updates
kernel-lt.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.132-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.13.2-1.el7.elrepo elrepo-kernel
kernel-tools.x86_64 3.10.0-1160.31.1.el7 updates
kernel-tools-libs.x86_64 3.10.0-1160.31.1.el7 updates
kernel-tools-libs-devel.x86_64 3.10.0-1160.31.1.el7 updates
libreport-plugin-kerneloops.x86_64 2.1.11-53.el7.centos base
texlive-l3kernel.noarch 2:svn29409.SVN_4469-45.el7 base
texlive-l3kernel-doc.noarch 2:svn29409.SVN_4469-45.el7 base
#说明
#kernel-lt 长期技术支持版本,稳定
#kernel-ml 主线版本 测试版
此处安装lt版本
[root@localhost ~]# yum install kernel-lt.x86_64
#导入key
Importing GPG key 0xBAADAE52:
Userid : "elrepo.org (RPM Signing Key for elrepo.org) <secure@elrepo.org>"
Fingerprint: 96c0 104f 6315 4731 1e0b b1ae 309b c305 baad ae52
Package : elrepo-release-7.0-5.el7.elrepo.noarch (@/elrepo-release-7.el7.elrepo.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
Is this ok [y/N]:y
安装完毕,此时系统上会存在两个两个内核,
重启可以看到启动界面显示两个内核,可以选择用新的内核或者旧的内核
查看内核版本
[root@localhost ~]# uname -r
5.4.132-1.el7.elrepo.x86_64
卸载新的内核
- 重启,使用旧的内核
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64
[root@localhost ~]# yum history
Loaded plugins: fastestmirror
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
25 | install kernel-lt.x86_64 | 2021-07-19 15:18 | Install | 1
24 | install https://www.elre | 2021-07-19 15:02 | Install | 1
[root@localhost ~]# yum history info 25
Loaded plugins: fastestmirror
Transaction ID : 25
Begin time : Mon Jul 19 15:18:02 2021
Begin rpmdb : 941:e30a98e76e9d11ac76c69fcce535711315e5ffc1
End time : 15:18:33 2021 (31 seconds)
End rpmdb : 942:c5d98b2bbddd3a1e799a3a379c0a4b4557bea8f9
User : root <root>
Return-Code : Success
Command Line : install kernel-lt.x86_64
Transaction performed with:
Installed rpm-4.11.3-40.el7.x86_64 @base
Installed yum-3.4.3-132.el7.centos.0.1.noarch @anaconda
Installed yum-plugin-fastestmirror-1.1.31-34.el7.noarch @anaconda
Packages Altered:
Install kernel-lt-5.4.132-1.el7.elrepo.x86_64 @elrepo-kernel
history info
#撤销第25步操作
[root@localhost ~]# yum history undo 25
Loaded plugins: fastestmirror
Undoing transaction 25, from Mon Jul 19 15:18:02 2021
Install kernel-lt-5.4.132-1.el7.elrepo.x86_64 @elrepo-kernel
Resolving Dependencies
--> Running transaction check
---> Package kernel-lt.x86_64 0:5.4.132-1.el7.elrepo will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================
Package Arch Version Repository Size
================================================================================================================
Removing:
kernel-lt x86_64 5.4.132-1.el7.elrepo @elrepo-kernel 227 M
Transaction Summary
================================================================================================================
Remove 1 Package
Installed size: 227 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : kernel-lt-5.4.132-1.el7.elrepo.x86_64 1/1
Verifying : kernel-lt-5.4.132-1.el7.elrepo.x86_64 1/1
Removed:
kernel-lt.x86_64 0:5.4.132-1.el7.elrepo
Complete!
本地升级内核
- 先用一台能上网的机器,把内核和依赖包下载下来
- 拷贝到需要升级的机器上
- rpm -ivh /data/kernel/* 即可实现升级 或者 yum install /data/kernel/*