gzip: stdout: No space left on device when doing apt-get -f install

If you've experience any of the above message then like me you've probably scoured Google looking for a solution. Many of the proposed commands don't actually fix anything. Thankfully it only takes a few to get things up and running again.

First lets start with the problem. You login to your Ubuntu Server (12.04 in my case) which has auto updates installed. Upon running the command sudo apt-get upgrade you end up with something like this

Setting up initramfs-tools (0.99ubuntu13.5) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-3.2.0-60-generic (3.2.0-60.91) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-61-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.2.0-60-generic /boot/vmlinuz-3.2.0-60-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-60-generic /boot/vmlinuz-3.2.0-60-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-60-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-60-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-60-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-60-generic (--configure):
subprocess installed post-installation script returned error exit status 2

This basically means means that your boot partition has filled up with unused kernels and there isn't any room to install another one.

The next thing to do is to run the following two commands dpkg -l 'linux-image-*' | grep '^ii' and cat /proc/version. These commands will list all the kernel versions installed and list the kernel your currently running.

Now you can use the command sudo dpkg --remove linux-image-3.2.0-54-generic to remove a few kernel versions that are unused. Make sure you don't remove the kernel your currently using.

After removing a few older kernels you can run apt-get upgrade again to finish installing the newest kernels.

Lastly use apt-get autoremove in order to automatically remove any other unused kernels.

Tags:

Comments

This one really helped me after googling and failing for so long... Thanks a lot!

You're very welcome

Extremely useful! thanks

Super Fun Time