Your /boot partition is screaming. You check the disk usage and find it’s somehow 95% full. Kernel updates. That’s always the culprit.
Every time Ubuntu or Debian installs a new kernel, it leaves the old one sitting there “just in case.” After a year, you’ve got 8 kernels installed and only one is actually running. It’s like a digital hoarder who says, “I might need this one day,” except you won’t. That day never comes.
Old kernels don’t uninstall themselves. You have to kick them out manually. The good news? It’s not complicated. The bad news? There’s a trap that’ll leave you staring at a black screen if you’re not careful.
Why Do Old Kernels Pile Up?
Package managers on Debian/Ubuntu systems don’t automatically nuke old kernels because someone, somewhere, might need to boot into them. It’s a reasonable philosophy, kernel bugs happen, and occasionally you need to revert to a known-good version. But after six months? After a year? You’re never going back.
Each kernel installation dumps files into /boot: the kernel image (vmlinuz-*), the init ramdisk (initrd.img-*), the system map (System.map-*). On a typical system, that’s 50-100 MB per kernel. With 8 kernels, that’s 400-800 MB gone, and if your /boot is only 512 MB (older systems), you’ve got a problem. You can’t install updates. You can’t update GRUB. You’re stuck.
Know Your Running Kernel
First, don’t panic. Check which kernel you’re actually using:
$ uname -r6.8.0-45-genericThat’s your current kernel (on Debian the suffix is -amd64 instead of -generic, and the package names follow that). Everything else on the system is excess baggage.
To see all installed kernels:
$ dpkg -l | grep linux-imageii linux-image-6.8.0-31-generic 6.8.0-31.31 amd64ii linux-image-6.8.0-39-generic 6.8.0-39.39 amd64ii linux-image-6.8.0-41-generic 6.8.0-41.41 amd64ii linux-image-6.8.0-45-generic 6.8.0-45.45 amd64See? Four kernels. Only one of them (6.8.0-45) is running. The other three are dead weight.
The Easy Way: apt autoremove
On current Ubuntu (24.04) and Debian (13), the simplest move is:
$ sudo apt autoremoveThat’s it. autoremove is smart enough to keep your running kernel and the newest installed one, and remove the older ones. That means two kernels stay behind by design (apt’s /etc/apt/apt.conf.d/01autoremove-kernels list holds the keep rules). Add --purge if you also want their config files gone.
But here’s the wisdom: always test first:
$ sudo apt autoremove --dry-runThis shows you what would be deleted without actually doing it. Look at the list. If you see your current kernel getting marked for removal, stop. Something’s wrong. Don’t run the actual command.
If the dry-run looks good, go ahead:
$ sudo apt autoremoveDone. Your /boot should have breathing room again.
The Manual Way: dpkg Purge
If autoremove doesn’t work or you want surgical precision, purge kernels by name. List them, pick the old versions, and purge exactly those:
$ uname -r$ dpkg -l 'linux-image-*' 'linux-modules-*' 'linux-headers-*' | grep ^ii$ sudo apt purge linux-image-6.8.0-31-generic linux-modules-6.8.0-31-generic linux-headers-6.8.0-31-genericWarning: the popular regex one-liners that purge “everything except the running kernel” are a trap. They also match a newer kernel you installed but have not rebooted into, they run with -y so there is no confirmation, and one wrong match leaves you without a bootable kernel. Type the versions yourself and read apt’s removal list before you say yes. Never purge the version uname -r prints, and keep at least one older kernel as a fallback.
purge removes the package and its config files, which frees more space than a plain remove.
The Proxmox Quirk
If you’re running Proxmox, the standard commands sometimes don’t work the same way because Proxmox uses its own kernel naming scheme. You might see kernels like proxmox-kernel-6.8.12-1-pve. On Proxmox, list what the boot tool knows about, remove old kernel packages with apt purge, then sync the boot partitions:
$ sudo proxmox-boot-tool kernel list$ sudo proxmox-boot-tool refreshrefresh copies the kernels that are still installed to every ESP and updates the boot entries. It does not delete kernel packages itself. Proxmox keeps the running kernel, the newest ones and the latest of the previous series by default.
How Many Kernels Should You Keep?
My rule: keep two. One running, one backup. If the current kernel has a showstopper bug, you boot into the previous one while you figure it out. If you keep three, you’re just hedging for a 1-in-100 edge case that’ll probably never happen.
On servers with automated backups and monitoring? Keep one. You’ll never reboot into an old kernel on prod anyway.
The Horror Story: Never Delete Your Running Kernel
Do not, under any circumstances, delete the kernel you’re currently running. I say this with the voice of experience. Someone always does it.
You run the purge command. It works. You reboot. Nothing happens. Just a black screen. System won’t boot.
Why? Because you accidentally nuked the kernel you’re using. Happened on a remote server in 2015, 2 AM, and I had to call a hosting provider to boot into a liveUSB just to fix it. That was a fun evening.
The fix: Use --dry-run first. Every time. No exceptions. And double-check that uname -r is never in that list of packages to be removed.
If you ever see your current kernel listed in the removal list, abort immediately and investigate.
Cleaning Up Proxmox (Special Case)
If your Proxmox node’s boot partition is full:
$ sudo proxmox-boot-tool refreshAfter you purge old kernel packages with apt, this resyncs the EFI boot entries so the ESP stops carrying the removed kernels. (Heads up: the old pve-efiboot-tool command was renamed to proxmox-boot-tool back in PVE 6.4, if a guide still references the old name, that’s why it’s gone.)
After Cleanup
Once you’ve removed the old kernels, regenerate your boot loader configuration:
$ sudo update-grubOn Proxmox, that’s already handled. Everywhere else, run it to be safe.
Check your /boot space:
$ df -h /bootFilesystem Size Used Avail Use% Mounted on/dev/sda1 487M 145M 318M 32% /bootMuch better. You’re not breaking a sweat anymore.
That’s it. Old kernels gone, /boot breathing again, and you still have a safety net if something goes sideways. Don’t hoard.