执行命令如下:
查看当前内核
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
查看所有内核
[root@localhost ~]# rpm -qa|grep kernel
kernel-3.10.0-957.27.2.el7.x86_64
kernel-devel-3.10.0-957.21.3.el7.x86_64
kernel-devel-3.10.0-957.27.2.el7.x86_64
abrt-addon-kerneloops-2.1.11-52.el7.centos.x86_64
kernel-3.10.0-957.21.3.el7.x86_64
kernel-3.10.0-862.el7.x86_64
kernel-tools-libs-3.10.0-957.21.3.el7.x86_64
kernel-headers-3.10.0-957.27.2.el7.x86_64
kernel-tools-3.10.0-957.21.3.el7.x86_64
移除不需要的内核
[root@localhost ~]# yum remove kernel-3.10.0-957.21.3.el7.x86_64 kernel-devel-3.10.0-957.21.3.el7.x86_64 kernel-tools-libs-3.10.0-957.21.3.el7.x86_64 kernel-tools-3.10.0-957.21.3.el7.x86_64 kernel-3.10.0-862.el7.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-957.21.3.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-862.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-957.21.3.el7 will be erased
---> Package kernel-tools.x86_64 0:3.10.0-957.21.3.el7 will be erased
---> Package kernel-tools-libs.x86_64 0:3.10.0-957.21.3.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================================================
Removing:
kernel x86_64 3.10.0-862.el7 @anaconda 62 M
kernel-devel x86_64 3.10.0-957.21.3.el7 @updates 37 M
kernel-tools x86_64 3.10.0-957.21.3.el7 @updates 288 k
kernel-tools-libs x86_64 3.10.0-957.21.3.el7 @updates 18 k
Transaction Summary
===============================================================================================================================================================================================
Remove 4 Packages
Installed size: 99 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : kernel-tools-3.10.0-957.21.3.el7.x86_64 1/4
Erasing : kernel-3.10.0-862.el7.x86_64 2/4
Erasing : kernel-devel-3.10.0-957.21.3.el7.x86_64 3/4
Erasing : kernel-tools-libs-3.10.0-957.21.3.el7.x86_64 4/4
Verifying : kernel-tools-libs-3.10.0-957.21.3.el7.x86_64 1/4
Verifying : kernel-tools-3.10.0-957.21.3.el7.x86_64 2/4
Verifying : kernel-devel-3.10.0-957.21.3.el7.x86_64 3/4
Verifying : kernel-3.10.0-862.el7.x86_64 4/4
Removed:
kernel.x86_64 0:3.10.0-862.el7 kernel-devel.x86_64 0:3.10.0-957.21.3.el7 kernel-tools.x86_64 0:3.10.0-957.21.3.el7 kernel-tools-libs.x86_64 0:3.10.0-957.21.3.el7
Complete!
查看删除效果
[root@localhost ~]# rpm -qa|grep kernel
kernel-3.10.0-957.27.2.el7.x86_64
kernel-devel-3.10.0-957.27.2.el7.x86_64
abrt-addon-kerneloops-2.1.11-52.el7.centos.x86_64
kernel-headers-3.10.0-957.27.2.el7.x86_64