Troubleshooting a full /boot partition on Ubuntu

A regular issue with systems running Ubuntu is that may fill up the /boot partition. After trying several options, we found a way to do this in three steps. And opposed to other solutions, there is no manual moving of files needed.

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 over night, 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

df -h

If so, then here are the steps to take.

Step 1: find and purge kernel packages

Find and purge all kernel packages, except the one we are running now:

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

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 command.

apt-get --yes autoremove

Did this help? 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.