Post Date: December 12, 2020
Last Updated: November 2026
Introduction
This guide explains how to fix the boot partition full issue in CentOS by removing old kernels the safe way. Every kernel update adds a new set of files to the /boot partition. CentOS keeps several older kernels by default, so a small /boot fills up after a few updates and later updates fail with “No space left on device”.
The original guide gave the right idea: limit the kernels with installonly_limit and clean up with package-cleanup. This version adds a disk check, a safe way to confirm the running kernel, the commands for CentOS 8 and later, a manual rescue for when yum itself fails, and troubleshooting.
Warning: When you fix the boot partition full issue, never delete files from
/bootby hand withrm. The files belong to installed kernel packages, and deleting them can leave the server unable to boot. Always remove kernels withyum,dnforrpm, and keep the kernel you are running now.
Prerequisites
Before you fix the boot partition full issue, make sure you have:
- Root or sudo access to the server over SSH
- The output of
df -h /boot, so you know how full the partition is - Console or out-of-band access if this is a production server, in case a reboot is needed
- A snapshot or backup of the server, if possible
- Knowledge of your package manager (
yumon CentOS 7,dnfon CentOS 8 and later)
Architecture
- Each kernel update installs a new
vmlinuz,initramfs,System.mapandconfigset into/boot - The
installonly_limitsetting in/etc/yum.confdecides how many kernel versions the package manager keeps - The CentOS 7 default is 5, and
/bootpartitions of 500 MB or less often cannot hold that many package-cleanup --oldkernelsremoves kernel packages beyond the number you set, newest ones are kept- Removing a kernel package also deletes its files from
/bootand updates the GRUB menu
The image below shows the workflow. For the official references, see the yum.conf manual and the DNF documentation on configuration options.

Steps to Fix the Boot Partition Full Issue in CentOS
1. Check the Disk and the Running Kernel
Log in to the server over SSH and look at /boot and the kernels installed:
df -h /boot uname -r rpm -q kernel --last
uname -r prints the kernel you are running now, and the original guide used uname -a, which prints more than you need. rpm -q kernel --last lists installed kernels with the newest first. Make sure the running kernel is one of the first two. If it is an older one, reboot into the newest kernel before you clean up.
2. Limit the Number of Kernels Kept
Back up the file, then set the limit:
sudo cp /etc/yum.conf /etc/yum.conf.bak sudo nano /etc/yum.conf
In the [main] section, add or change this line:
installonly_limit=2
This setting stops the boot partition full issue from coming back, because later updates remove the oldest kernel automatically. Two is the smallest value yum accepts. It keeps the current kernel and one fallback.

3. Install yum-utils
The package-cleanup command comes from this package:
sudo yum install yum-utils
4. Remove Old Kernels to Clear the Boot Partition Full Issue
Run the cleanup and keep the two newest kernels:
sudo package-cleanup --oldkernels --count=2
The command lists the packages it will remove and asks for confirmation. Check that the running kernel from Step 1 is not in the list, then type y. To skip the prompt in a script, add -y.
Note: For CentOS 8, Stream, AlmaLinux and Rocky Linux, use
dnfinstead. Setinstallonly_limit=2in/etc/dnf/dnf.conf, then runsudo dnf remove --oldinstallonly --setopt installonly_limit=2 kernel.
5. Verify the Result
df -h /boot rpm -q kernel sudo grubby --default-kernel
/boot should now show free space, only two kernels should remain, and the default kernel should be the newest one. If possible, reboot once in a maintenance window to confirm the server starts normally.
Troubleshooting
If the boot partition full issue continues, check these:
- “At least 25MB more space needed on the /boot filesystem.”:
yumcannot install the new kernel because/bootis full. Free space first by removing the oldest kernel package withrpm, as shown in the next bullet, then runyum updateagain yumcannot run because/bootis full: List the kernels withrpm -q kernel --last, pick the oldest one that is not the running kernel, and remove it withsudo rpm -e kernel-3.10.0-1160.el7.x86_64(use your own version string). Never remove the running kernel- “package-cleanup: command not found”: Install the package first with
sudo yum install yum-utils - “yum: command not found”: The server runs CentOS 8 or later. Use the
dnfcommands in the Note under Step 4 - The boot partition full issue returns after a few updates:
installonly_limitwas not saved in the[main]section, or a repeat entry later in the file overrides it. Check withgrep installonly_limit /etc/yum.conf /bootis still almost full after cleanup: The partition is too small for even two kernels, which can happen with a 200 MB/boot. Remove unused extras such as oldinitramfsrescue images only if you know how to rebuild them, or plan to resize the partition- The server booted into an old kernel after cleanup: The default entry in GRUB points to a removed kernel. Run
sudo grubby --default-kerneland set the newest kernel withsudo grubby --set-default /boot/vmlinuz-<newest-version>
Conclusion
To fix the boot partition full issue in CentOS, check df -h /boot and uname -r, set installonly_limit=2, install yum-utils, and run package-cleanup --oldkernels --count=2. Keep the running kernel and one fallback, and never delete files from /boot by hand. Because the limit now removes old kernels during each update, the problem should not return. CentOS 7 is also end of life, so plan a move to a supported system such as AlmaLinux or Rocky Linux.
Frequently Asked Questions (FAQs)
What causes the boot partition full issue in CentOS?
Each kernel update stores its files in /boot, and CentOS keeps several old kernels by default. A small /boot partition runs out of space after a few updates.
Is it safe to delete old kernels from /boot?
Yes, if you remove them with the package manager and keep the running kernel plus one fallback. Don’t delete the files by hand.
How many kernels should I keep?
Two is a good minimum. It keeps the current kernel and one older kernel you can boot into if the new one has a problem.
Does this work on CentOS 8, AlmaLinux and Rocky Linux?
The idea is the same, but those systems use dnf. Set installonly_limit in /etc/dnf/dnf.conf and use dnf remove --oldinstallonly.
Related Articles
How to Install Let’s Encrypt with Apache on CentOS 7
How to Add Swap Memory on AWS EC2 Linux Instance
Talk to Our Technology Experts
Tired of disk space alerts and failed updates on your servers? Our team can monitor, patch, and maintain your Linux systems through our Software Maintenance and Support services.
Connect with our technology experts.
