Many servers keep the files needed to start Linux in a small separate partition, /boot. Every kernel update adds a new kernel there, and when it fills up, updates fail with errors such as:
installing package kernel-core-5.14.0-570.el9.x86_64 needs 42MB more space on the /boot filesystem
The fix is to remove old kernels you no longer use. This guide shows how to do that safely, on AlmaLinux, CloudLinux and Ubuntu, with or without cPanel.
Quick answer
On AlmaLinux or CloudLinux, remove old kernels and keep the newest two plus the one running now:
dnf remove --oldinstallonly --setopt installonly_limit=2 kernel
On Ubuntu:
apt autoremove --purge
Then check with df -h /boot. DNF
What you need: root access.
Step 1: Confirm /boot is full
df -h /boot
Filesystem Size Used Avail Use% Mounted on
/dev/md0 974M 974M 0 100% /boot
If /boot is not listed separately, it is part of /, and the problem is the main disk; see How to Check Disk Space in Linux.
Step 2: Note the running kernel
uname -r
This is the kernel the server is using right now. Never remove it. The commands below protect it automatically, but check before and after anyway.
Step 3: List the installed kernels
On AlmaLinux or CloudLinux:
rpm -q kernel
On Ubuntu:
dpkg --list 'linux-image-*' | grep '^ii'
You will usually see several versions. Only the running one and the newest are really needed; one older kernel is worth keeping as a fallback.
Step 4: Remove the old kernels
AlmaLinux, CloudLinux and other RHEL-based systems
dnf remove --oldinstallonly --setopt installonly_limit=2 kernel
This removes old kernels and keeps the latest versions plus the version of the running kernel. DNF DNF lists what it will remove and asks before doing it; check that the version from Step 2 is not in the list, then answer y.
If /boot is so full that dnf itself fails, remove one old kernel by name first to make room, for example:
dnf remove kernel-core-5.14.0-427.13.1.el9_4.x86_64
Use a version from the Step 3 list that is neither the running one nor the newest.
Ubuntu
apt autoremove --purge
This removes kernels that are no longer needed while keeping the running one and the newest. Check the list apt shows before you confirm.
If apt itself fails because /boot is full, remove one old kernel by name first:
apt purge linux-image-6.8.0-31-generic
Again, use a version that is neither running nor the newest.
Step 5: Check the result
df -h /boot
rpm -q kernel # or, on Ubuntu: dpkg --list 'linux-image-*' | grep '^ii'
/boot should have free space again, and the running kernel from Step 2 should still be listed. Now finish the update that failed, for example dnf update or apt upgrade.
Stop it from filling up again
On AlmaLinux and CloudLinux, DNF keeps 3 kernels by default. You can lower that to 2, the smallest allowed value, in /etc/dnf/dnf.conf: DNF
[main]
installonly_limit=2
From then on, each kernel update removes the oldest kernel automatically.
On Ubuntu, run apt autoremove --purge after kernel updates, or let unattended upgrades do it.
If /boot is very small (some older servers have only 200–500 MB), even two or three current kernels may not fit. In that case the long-term fix is a larger /boot partition, which usually means reinstalling the server.
On cPanel servers
These steps are the same on a cPanel server. cPanel does not manage the kernel; it comes from the operating system (or from CloudLinux, on CloudLinux servers). Do the cleanup outside busy hours, and reboot afterwards only if a new kernel was installed by the update.