前言:
在升级系统的时候提示/boot分区空间不足,导致无法安装升级。当你/boot分区空间比较小的话,就需要清除老版本的kernel来是释放空间,来安装新的kernel。
本文将介绍在RHEL系统中如何快捷的清除旧版本的kernel.
一、检查已安装的kernel
[root@ops ~]# rpm -q kernelkernel-2.6.32-358.el6.x86_64kernel-2.6.32-573.12.1.el6.x86_64
二、删除旧的kernel
## 安装yum-utils #### Fedora 23/22 ##dnf install yum-utils ## Fedora 21/20/19/18/17/16, CentOS, Red Hat (RHEL) ##yum install yum-utils ## 使用Package-cleanup保留2个版本的kernel(count后面跟要保留的个数) ##package-cleanup --oldkernels --count=2
如下所示:
[root@ops ~]# package-cleanup --oldkernels --count=1Loaded plugins: fastestmirror--> Running transaction check---> Package kernel.x86_64 0:2.6.32-358.el6 will be erased--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================== Package Arch Version Repository Size========================================================================================================================Removing: kernel x86_64 2.6.32-358.el6 @anaconda-CentOS-201303020151.x86_64/6.4 116 MTransaction Summary========================================================================================================================Remove 1 Package(s)Installed size: 116 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Erasing : kernel-2.6.32-358.el6.x86_64 1/1 Verifying : kernel-2.6.32-358.el6.x86_64 1/1 Removed: kernel.x86_64 0:2.6.32-358.el6 Complete!
三、限制kernel安装数量
通过配置yum或者dnf来限制安装kernel的数量
编辑/etc/yum.conf 或者/etc/dnf/dnf.conf 配置installonly_limit:
installonly_limit=2
这样就可以限制最多只会装2个版本的内核。
原文: