Can't clean a full /boot because of unmet dependencies

In such case I would use the dpkg tool to force the removal of some kernel packages. This is not suggested for common use and is a bit dangerous, but in such case with unmet dependencies might help.

First of all locate the kernel in which the system is booted. The one that is currently loaded. Open a terminal (CTRL+ALT+T) and issue the following command

uname -r

It will show you the loaded kernel, you should NOT try to remove this one.

Then issue the command

ls /boot 

it will return all the installed images. Pick one or two and try to remove them. Try to force remove/purge them. For example

sudo dpkg --force-all -P linux-image-3.13.0-32-generic

You can do the same for other images, in order to free up some space.

Then you can try to install the missing packages, or

sudo apt-get install -f 

to try resolve the dependencies.

Finally, issue the "cleanup old kernels" command

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

Above command will remove ALL the kernels except the one that is currently loaded.

Because you have a separate /boot partition, keep in mind you will need to track its space and cleaning up often (the frequency depends on the space of /boot)


This is what worked for me on Ubuntu 16.04.

sudo apt autoremove --purge
sudo apt autoremove
sudo apt-get -f install
sudo apt-get upgrade

List all kernels:

dpkg --list 'linux-image*'

Display current kernel:

uname -r

List all kernels EXCEPT current one:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'

Make sure your current kernel isn't on that list.

Remove all kernels EXCEPT current one:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge

Clear other stuff:

sudo apt-get autoremove

If it stills throws any error then repeat following commands to remove unwanted kernels,

sudo dpkg --purge linux-image-X.X.X-XXX-generic linux-image-extra-X.X.X-XXX-generic linux-signed-image-X.X.X-XXX-generic
sudo dpkg --purge linux-image-Y.Y.Y-YYY-generic linux-image-extra-Y.Y.Y-YYY-generic linux-signed-image-Y.Y.Y-YYY-generic

sudo apt-get -f install

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge