/boot is full. No space left!

What do you do! You have a dependency not met so every time you try to run apt-get autoremove it fails. /boot has 100% utilization and it’s not looking good.

This is the nightmare I just lived for the past day or so. I thought about how I could solve this issue for a bit, crossed my fingers and tried it. (After I made backups duh!)


Find what kernel you’re using

uname –r

This kernel you won’t want to mess with until everything is solved. Make note of this and do not delete.


List all installed kernels

dpkg –list ‘linux-image*’


Now remove all old kernels

sudo apt-get remove linux-image-2.6.32-40-generic


If that fails because /boot still doesn’t have room then you’re going to need to improvise.

cd /boot

rm vmlinuz-2.6.32-40-generic-pae


This will get you some temporary room.  See how much room is available and delete more unused files if necessary.

df –h


Now that you have some free room remove everything old!

apt-get autoremove


User submitted code by Ahmad came up with an awesome trick

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

Using apt-get autoremove freed up around 40MB space in my case. However, Ahmad’s script freed up over 1GB of unused crap. Great share!