How to solve boot partition full issue in CentOS

Boot partition full issue in CentOS fixed by removing old kernels

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 /boot by hand with rm. The files belong to installed kernel packages, and deleting them can leave the server unable to boot. Always remove kernels with yum, dnf or rpm, 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 (yum on CentOS 7, dnf on CentOS 8 and later)

Architecture

  • Each kernel update installs a new vmlinuz, initramfs, System.map and config set into /boot
  • The installonly_limit setting in /etc/yum.conf decides how many kernel versions the package manager keeps
  • The CentOS 7 default is 5, and /boot partitions of 500 MB or less often cannot hold that many
  • package-cleanup --oldkernels removes kernel packages beyond the number you set, newest ones are kept
  • Removing a kernel package also deletes its files from /boot and 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 dnf instead. Set installonly_limit=2 in /etc/dnf/dnf.conf, then run sudo 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.”: yum cannot install the new kernel because /boot is full. Free space first by removing the oldest kernel package with rpm, as shown in the next bullet, then run yum update again
  • yum cannot run because /boot is full: List the kernels with rpm -q kernel --last, pick the oldest one that is not the running kernel, and remove it with sudo 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 dnf commands in the Note under Step 4
  • The boot partition full issue returns after a few updates: installonly_limit was not saved in the [main] section, or a repeat entry later in the file overrides it. Check with grep installonly_limit /etc/yum.conf
  • /boot is 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 old initramfs rescue 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-kernel and set the newest kernel with sudo 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.

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.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Comment

Scroll to Top