With every kernel update the previous version stays on disk. That is intentional – if the new kernel causes trouble, you can boot the old one from the GRUB menu. Over time, however, many versions pile up. Especially with a small /boot partition this leads to errors such as “No space left on device” during updates.
Taking stock
uname -r # running kernel – NEVER remove it
dpkg --list 'linux-image*' | grep ^ii # installed kernels
df -h /boot # free space on /boot
The easy way: apt autoremove
sudo apt autoremove --purge
apt automatically keeps the running and the newest kernel (and usually one more as a fallback) and removes all older ones including their headers and modules. This works on Ubuntu, Debian, Linux Mint and Proxmox. The purge-old-kernels script that used to be recommended is obsolete and no longer needed.
Tip: only clean up after a kernel update once you have rebooted into the new kernel – otherwise the old one still counts as “running”.
Removing specific kernels by hand
Kernels that were installed manually are not touched by autoremove. Remove those one by one – for example:
sudo apt purge linux-image-6.8.0-45-generic linux-headers-6.8.0-45-generic linux-modules-6.8.0-45-generic
Replace the version number with one from the list above, of course – and never use the one from uname -r.
When /boot is already full
If /boot is 100 % full, apt itself often fails because a half-installed kernel package is pending. In that case, first free up space by deleting the initrd image of the oldest kernel, then repair apt:
ls -lh /boot
sudo rm /boot/initrd.img-6.8.0-40-generic # an OLD kernel only!
sudo apt --fix-broken install
sudo apt autoremove --purge
Fedora
Fedora keeps three kernels by default. The number is set as installonly_limit=3 in /etc/dnf/dnf.conf. To remove older kernels right away:
sudo dnf remove --oldinstallonly
If you are building drivers via DKMS, you only need the headers of the running kernel – how to install them is covered in the article installing kernel headers. And if it is not /boot but the whole disk that is full, ncdu helps you track down the culprit. Seeing LVM warnings after a release upgrade? See fixing the “old PV header” warning.
Revised in November 2026 and merged with the contents of an older article for Ubuntu 10.04.