Troubleshooting a full /boot partition on Ubuntu

A regular issue with systems running Ubuntu is that may fill up the /boot partition. You might have discovered it when running apt, which refused to work. That is unfortunate, as you also need apt to resolve the issue. After trying several options, we found a way to resolve this catch 22, with just three steps. Opposed to other solutions, you don’t need to move files or do other tricky things on your system. Still a word of caution: any tasks you run on your system is your own responsibility. When possible, make backups, snapshots, etc.

The error: Unmet dependencies

Typically you will discover if the unmet dependencies error shows up. For some reason, one package depends on the other. This typically happens overnight, especially if you use a tool like unattended-upgrade for automatic patching.

root@system:/tmp# apt upgrade
Reading package lists... Done
Building dependency tree 
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
linux-image-extra-4.4.0-93-generic : Depends: linux-image-4.4.0-93-generic but it is not installed
linux-image-generic : Depends: linux-image-4.4.0-93-generic but it is not installed
Recommends: thermald but it is not installed
E: Unmet dependencies. Try using -f.


The first step is to confirm that this issue is really caused by a full /boot partition. Our friendly df command can help here.

df -h /boot

If the usage column shows 100%, then it is full. Time to take the next steps.

Step 1: find and purge kernel packages

The first step is to find all kernel packages, except the one we are running now. This is done with the inner dpkg command. The outer (first) dpkg command then purges the output that we received.

dpkg --purge $(dpkg -l linux-{image,image-extra,headers}-"[0-9]*" | awk '/^ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

Tip: run first the dpkg -l command to see what output is returned.

When the command runs, you may still get some errors like no space left on device. That is fine, as that will resolve after a few packages.

Screenshot of Ubuntu system with full boot partition and no space left on device error

Step 2: add missing packages

Now run the suggested apt-get command. Use --yes if you automatically want to answer yes to the related questions asked.

apt-get --yes -f install

Step 3: remove unneeded packages

Time to clean up by using the autoremove parameter.

apt-get --yes autoremove

Now your system should have free space again on the /boot partition.

Did this resolve your issue as well? Let us know in the comments.

One more thing...

Keep learning

So you are interested in Linux security? Join the Linux Security Expert training program, a practical and lab-based training ground. For those who want to become (or stay) a Linux security expert.

See training package

Lynis Enterprise screenshot to help with system hardeningSecurity scanning with Lynis and Lynis Enterprise

Run automated security scans and increase your defenses. Lynis is an open source security tool to perform in-depth audits. It helps with system hardening, vulnerability discovery, and compliance.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.