If you have ever got this popup warning on CentOS/RedHat 7 this post may help. This happened to me and when I looked at “/boot” it looked like:
You can see there is the current kernel and three previous kernels to choose from:
CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_6) 7 (Core)
CentOS Linux (0-rescue-71c11ed5c0aa41ad909ab96d4c6ad395) 7 (Core)
This aligns with the 4 options you have at boot:
Next check you have the RPM “yum-utils” installed. Then run the following which is included in yum-utils:
package-cleanup –oldkernels –count=1
This will automatically delete and free up space by erasing old kernels and leaving with the current one plus the “rescue” kernel. When this runs you will see something that includes the following:
Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : kernel.x86_64 1/4 Erasing : kernel-devel.x86_64 2/4 Erasing : kernel.x86_64 3/4 Erasing : kernel-devel.x86_64 4/4 Verifying : kernel-devel-3.10.0-957.el7.x86_64 1/4 Verifying : kernel-3.10.0-957.el7.x86_64 2/4 Verifying : kernel-devel-3.10.0-957.21.3.el7.x86_64 3/4 Verifying : kernel-3.10.0-957.21.3.el7.x86_64 4/4 Removed: kernel.x86_64 0:3.10.0-957.el7 kernel.x86_64 0:3.10.0-957.21.3.el7 kernel-devel.x86_64 0:3.10.0-957.el7 kernel-devel.x86_64 0:3.10.0-957.21.3.el7 Complete!
Now you should fine the “/boot” is much emptier:
So when you reboot, you likewise only get the two kernel boot options:
To stop this happening edit the file “/etc/yum.conf” and look for the line:
Change the number to the one you want. Note that if you put either 0 or 1 then it will be interpreted as unlimited. So for practical purposes the minimum is 2. I set mine to 2.
Linux Config: How to remove old unused kernels on CentOS Linux