DPKG – Fixing ‘gzip: stdout: No Space Left on Device’ While Upgrading the Kernel

dpkg

I see the following error while trying run the command shown below. I read somewhere that my /boot partition is low on disk space. How can I increase the size of the /boot partition so I can install more software? I have a 500GB hard disk, so there is enough space to play with.

sudo apt-get install libdvdread4

gzip: stdout: No space left on device                                                                                                                                                                              
   E: mkinitramfs failure cpio 141 gzip 1                                                                                                                                                                             
   update-initramfs: failed for /boot/initrd.img-3.2.0-33-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-33-generic.postinst line 1010.                                                                                                    
   dpkg: error processing linux-image-3.2.0-33-generic (--configure):                                                                                                                                                 
    subprocess installed post-installation script returned error exit status 2                                                                                                                                        
   dpkg: dependency problems prevent configuration of linux-image-server:                                                                                                                                             
   linux-image-server depends on linux-image-3.2.0-33-generic; however:                                                                                                                                              
     Package linux-image-3.2.0-33-generic is not configured yet.
   dpkg: error processing linux-image-server (--configure):
    dependency problems - leaving unconfigured
   dpkg: dependency problems prevent configuration of linux-server:
    linux-server depends on linux-image-server (= 3.2.0.33.36); however:
     Package linux-image-server is not configured yet.
   dpkg: error processing linux-server (--configure):
    dependency problems - leaving unconfigured
   No apport report written because the error message indicates its a followup error from a   previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
 Errors were encountered while processing:
 linux-image-3.2.0-33-generic
 linux-image-server
 linux-server
N: Ignoring file 'michael-gruz-canon-precise.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'michael-gruz-canon-precise.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension

Listed below is the output of du

Filesystem              1K-blocks      Used Available Use% Mounted on
/dev/mapper/ubuntu-root 712660664 104095912 572363692  16% /
udev                      3964792         4   3964788   1% /dev
tmpfs                     1591012      1064   1589948   1% /run
none                         5120         0      5120   0% /run/lock
none                      3977528       684   3976844   1% /run/shm
/dev/sda1                  233191    219821       929 100% /boot

Best Answer

You have a separate partition for /boot that is only around 227MB in size. This partition is full.

The reason Ubuntu has given you a separate parition for /boot seems to be that you are using LVM and/or "full" disk encryption on the rest of the drive.

The /boot directory contains all of your kernel images, so the likely cause of this issue is that you have too many previous kernels installed. Ubuntu issues kernel updates which bump the version number in the package name fairly frequently even for long term stable versions, so over time if you keep the system up to date, the /boot directory will grow.

You should be able to list your installed kernels with

aptitude search ~ilinux-image

(Note that this will probably return packages that aren't kernels, too).

There is usually no need for more than two kernels to be installed - the one currently in use and the previous known working kernel (as a fallback). So you can start removing the older ones, one by one, like this:

sudo apt-get autoremove linux-image-3.2.0-23-generic

Make sure you substitute "3.2.0-23-generic" with the actual kernel version you want to remove! Also, don't remove packages such as linux-image-generic. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).

You can find your currently running kernel with:

uname -r

Here's an illustrated guide to doing what I've just explained. This article uses slightly different tools but basically the same approach.

Related Question