Recently done some work on tweaking the centos7 system to run a newer kernel version. Similar to:
https://wiki.mikejung.biz/CentOS_7
However, upon installing a newer kernel and rebooting the system, I discovered the /boot file system had 6MB of free space left. Apparently, time for a cleanup. Here are the steps I used to clean up space, by wiping out some older kernels.
First, we determine what kernels are there:
rpm -q
kernel-3.10.0-327.36.2.el7.x86_64
kernel-3.10.0-327.36.3.el7.x86_64
kernel-3.10.0-514.2.2.el7.x86_64
kernel-3.10.0-514.10.2.el7.x86_64
Discover the running kernel with: uname -r
Running a kernel-4 version, so the old ones can go. To remove them you need to install the yum-utils package, if it isn’t already installed.
sudo yum install yum-utils
Once it’s installed we use the package-cleanup tool to remove the old kernels. However, you may wish to keep one. Just in case issues arise at some point with your running kernel. This is accomplished with:
sudo package-cleanup --oldkernels --count=1
Loaded plugins: fastestmirror, langpacks
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-327.36.2.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-327.36.3.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-514.2.2.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-327.36.2.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-327.36.3.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-514.2.2.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Removing:
kernel x86_64 3.10.0-327.36.2.el7 @updates 136 M
kernel x86_64 3.10.0-327.36.3.el7 @updates 136 M
kernel x86_64 3.10.0-514.2.2.el7 @updates 148 M
kernel-devel x86_64 3.10.0-327.36.2.el7 @updates 33 M
kernel-devel x86_64 3.10.0-327.36.3.el7 @updates 33 M
kernel-devel x86_64 3.10.0-514.2.2.el7 @updates 34 M
Transaction Summary
===================================================================================================
Remove 6 Packages
Installed size: 520 M
Is this ok [y/N]:
Clicking yes will erase those old kernels and remove them from your grub startup list. You can confirm they are gone with: rpm -q
command.