Full /boot partition on Ubuntu

I use Ubuntu for my htpc.  I went to update it today and it failed because the /boot partition had been filled.  Here’s how I cleaned that up.

When I ran apt-get update and apt-get upgrade, it failed with the following message:

update-initramfs: Generating /boot/initrd.img-3.13.0-76-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-76-generic with 1.
No apport report written because MaxReports is reached already
                                                              dpkg: error processing package initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Sure enough, if I look at /boot, it has been filled up with all the previous kernels and associated packages:

htpc@htpc:~$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       237M  231M     0 100% /boot

I don’t use Ubuntu often so I had to search around and sort of combine some commands, but here is what I came up with in order to clean up all the kernels except the currently running one:

sudo apt-get purge \
  $(dpkg --list 'linux-image*' | \
  awk '/'$(uname -r)'/ {next;}; /^ii/ {print $2;}')

It should be noted that I’m not sure if purge or remove is more appropriate, but purge seemed to free up the space and I was able to update the rest of the packages.



1 Comment for “Full /boot partition on Ubuntu”


I use this often. Recommend to others. Can’t understand why Ubuntu doesn’t automatically delete old kernels. They wonder why Linux hasn’t gone mainstream. I’d never recommend Ubuntu to a non tech person on this one alone. Although love using it myself

Leave a Reply

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