Monthly Archives: June 2013

Removing old Linux Kernels In Ubuntu

Ever get this on linux?

$ df -h /boot/
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 228M 228M 0M 100% /boot

Looks like ubuntu has been updating the kernels without cleaning itself up. Bad ubuntu! And it is terrible that the default boot partition is only 230MB. A quick google search gives me this one-liner:

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

Thanks tuxtweats! http://tuxtweaks.com/2010/10/remove-old-kernels-in-ubuntu-with-one-command/

**UPDATE**: You don’t have to do this anymore… You can now just do:

1
$ sudo apt-get autoremove

This will clean up old kernels. The only way this won’t work is if you’re at 100%. Then you have to clear a few old kernels out manually and then resume installation of the latest kernel, then run the autoremove command.