Remove Old Kernels in Ubuntu (Debian) to free up space on the /boot

While trying to run updates and upgrades on one of my Ubuntu 13.10 servers, I ran into a problem where the upgrade process would not complete because the /boot partition, which is where all kernels are stored, was full.  Running “sudo apt-get autoremove” was not helping me and the lack of space was not allowing the system to clear up this space.  I started to panic. So I reached out to a friend who has been down this road before and he immediately shared this with me:

You cannot just go into this location and start deleting files.  You are messing with the kernel and it’s ability to load the system.  Fair warning! Make sure you have a backup before you proceed.

Running the following command cleared up that /boot partition by deleting all kernels except the one the system needs to boot.

That is all on one line sot just copy and past if you would like.  This command also updates GRUB so no need to do so manually.

Verify that your /boot partition is cleared up by running:

You should see that you now have reclaimed the free space you need.  Just remember to run “sudo apt-get autoremove” after you run updates to avoid needing this article in the first place.

Now get back to updating your system!

Thanks to J.P. for this tidbit!