Michał Kowol Tech Blog

/boot 100% and can't purge

Overview

Sometimes, during updating your ubuntu, you get a problem with full /boot directory. The sandard ways to clear that directories fail and you need to find better solution to this problem.

Solution

  1. sudo apt-get install - fix-broken should fail but list unused packets
  2. free them one by one using sudo dpkg --purge .... If a packet refuse to uninstall due to dependencies, just advance to the next one.
  3. After uninstalling everything you could, sudo apt-get install --fix-broken again, and this time it should work.

So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:

To list all installed kernels, run:

dpkg -l linux-image-\* | grep ^ii

Command to show all kernels and headers that can be removed, excluding the current running kernel:

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

So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:

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