Boot Drive full Ubuntu 16 (can’t sudo apt-get upgrade)

I was getting the following error when I attempted to “sudo apt-get update” on my ubuntu 16.

VM.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-103-generic : Depends: linux-image-4.4.0-103-generic but it is not going to be installed
linux-image-extra-4.4.0-104-generic : Depends: linux-image-4.4.0-104-generic but it is not going to be installed
linux-image-extra-4.4.0-108-generic : Depends: linux-image-4.4.0-108-generic but it is not going to be installed
linux-image-extra-4.4.0-109-generic : Depends: linux-image-4.4.0-109-generic but it is not going to be installed
linux-image-extra-4.4.0-112-generic : Depends: linux-image-4.4.0-112-generic but it is not going to be installed
linux-image-extra-4.4.0-116-generic : Depends: linux-image-4.4.0-116-generic but it is not going to be installed
linux-image-extra-4.4.0-119-generic : Depends: linux-image-4.4.0-119-generic but it is not going to be installed
linux-image-extra-4.4.0-128-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
linux-image-extra-4.4.0-75-generic : Depends: linux-image-4.4.0-75-generic but it is not going to be installed
linux-image-generic : Depends: linux-image-4.4.0-128-generic but it is not going to be installed
Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).

Basically the boot partition was full and the old unused kernels needed to be deleted safely to free up the required space for the update.

The Solution I used. (references are linked at the end of the post.)

Step 1: Get your current boot kernel

uname -r

Step 2:  list all installed kernels

dpkg -l | grep -G "linux.*image.*"

output

Step 3: Delete unused kernel to free up some space on the boot drive

sudo dpkg --force-all -P ****installed kernel name from prev command*****

Example: sudo dpkg --force-all -P linux-image-4.4.0-104-generic

Step 4: Install missing packages

sudo apt-get install -f

Step 5: remove all kernels except the currently loaded one

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

The above command took some time on my vm

Step 6: Optional but I would say do it just to make sure your system is up to date.

sudo update

then

sudo upgrade

References 

https://askubuntu.com/questions/585736/cant-clean-a-full-boot-because-of-unmet-dependencies

https://ubuntuforums.org/showthread.php?t=2254523

Leave a Reply

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