dpkg: error processing linux-image-amd64

After running

apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get install -f
dpkg --configure -a

I get the following Error:

 dpkg   --configure -a
    Setting up initramfs-tools (0.112) ...
    update-initramfs: deferring update (trigger activated)
    Setting up linux-image-3.8-2-amd64 (3.8.13-1) ...
    Running depmod.
    vmlinuz(/boot/vmlinuz-3.8-2-amd64
    ) points to /boot/vmlinuz-3.8-2-amd64
     (/boot/vmlinuz-3.8-2-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.8-2-amd64.postinst line 268.
    The link /initrd.img is a dangling linkto /boot/initrd.img-3.8-2-amd64
    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.8-2-amd64 /boot/vmlinuz-3.8-2-amd64
    update-initramfs: Generating /boot/initrd.img-3.8-2-amd64

    gzip: stdout: No space left on device
    E: mkinitramfs failure cpio 141 gzip 1
    update-initramfs: failed for /boot/initrd.img-3.8-2-amd64 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.8-2-amd64.postinst line 696.
    dpkg: error processing linux-image-3.8-2-amd64 (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of linux-image-amd64:
     linux-image-amd64 depends on linux-image-3.8-2-amd64; however:
      Package linux-image-3.8-2-amd64 is not configured yet.

    dpkg: error processing linux-image-amd64 (--configure):
     dependency problems - leaving unconfigured
    Processing triggers for initramfs-tools ...
    update-initramfs: Generating /boot/initrd.img-3.2.0-4-amd64

    gzip: stdout: No space left on device
    E: mkinitramfs failure cpio 141 gzip 1
    update-initramfs: failed for /boot/initrd.img-3.2.0-4-amd64 with 1.
    dpkg: error processing initramfs-tools (--configure):
     subprocess installed post-installation script returned error exit status 1
    Errors were encountered while processing:
     linux-image-3.8-2-amd64
     linux-image-amd64
     initramfs-tools

Output of df -h

Filesystem            Size  Used Avail Use% Mounted on
rootfs                 34G  8.4G   24G  27% /
udev                   10M     0   10M   0% /dev
tmpfs                  50M  220K   50M   1% /run
/dev/mapper/vg0-root   34G  8.4G   24G  27% /
tmpfs                 5.0M     0  5.0M   0% /run/lock
tmpfs                 100M     0  100M   0% /run/shm
/dev/sda2             179M   19M  151M  12% /boot
/dev/mapper/vg0-tmp   1.9G   35M  1.8G   2% /tmp

Output of df -i

df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
rootfs         3555328 108372 3446956    4% /
udev            126899    331  126568    1% /dev
tmpfs           128378    273  128105    1% /run
/dev/sda3      3555328 108372 3446956    4% /
tmpfs           128378      4  128374    1% /run/lock
tmpfs           128378      2  128376    1% /run/shm
/dev/sda2        48672    304   48368    1% /boot
/dev/sda6       124928     21  124907    1% /tmp

Contents of /boot

ls -l /boot
total 77941
-rw-r--r-- 1 root root   106193 Feb 25 04:02 config-2.6.32-5-amd64
-rw-r--r-- 1 root root   130657 Feb  5  2012 config-3.2.0-1-amd64
-rw-r--r-- 1 root root   128954 Jun 11  2012 config-3.2.0-2-amd64
-rw-r--r-- 1 root root   128986 Jul 23  2012 config-3.2.0-3-amd64
-rw-r--r-- 1 root root   129038 May 16 00:01 config-3.2.0-4-amd64
-rw-r--r-- 1 root root   139218 May 16 15:15 config-3.8-2-amd64
drwxr-xr-x 5 root root     5120 May 22 11:58 grub
-rw-r--r-- 1 root root  9152728 Mar  3 18:16 initrd.img-2.6.32-5-amd64
-rw-r--r-- 1 root root 10103130 Mar 11  2012 initrd.img-3.2.0-1-amd64
-rw-r--r-- 1 root root 10144903 Jul 23  2012 initrd.img-3.2.0-2-amd64
-rw-r--r-- 1 root root 10153801 Nov 25 12:26 initrd.img-3.2.0-3-amd64
-rw-r--r-- 1 root root 10706204 May 22 11:56 initrd.img-3.2.0-4-amd64
drwxr-xr-x 2 root root    12288 Jan 16  2012 lost+found
-rw-r--r-- 1 root root  1667905 Feb 25 04:02 System.map-2.6.32-5-amd64
-rw-r--r-- 1 root root  2073076 Feb  5  2012 System.map-3.2.0-1-amd64
-rw-r--r-- 1 root root  2091890 Jun 11  2012 System.map-3.2.0-2-amd64
-rw-r--r-- 1 root root  2095153 Jul 23  2012 System.map-3.2.0-3-amd64
-rw-r--r-- 1 root root  2105522 May 16 00:01 System.map-3.2.0-4-amd64
-rw-r--r-- 1 root root  2278502 May 16 15:15 System.map-3.8-2-amd64
-rw-r--r-- 1 root root  2426880 Feb 25 03:59 vmlinuz-2.6.32-5-amd64
-rw-r--r-- 1 root root  2779472 Feb  5  2012 vmlinuz-3.2.0-1-amd64
-rw-r--r-- 1 root root  2819504 Jun 11  2012 vmlinuz-3.2.0-2-amd64
-rw-r--r-- 1 root root  2822928 Jul 23  2012 vmlinuz-3.2.0-3-amd64
-rw-r--r-- 1 root root  2833376 May 15 23:58 vmlinuz-3.2.0-4-amd64
-rw-r--r-- 1 root root  2429168 May 16 15:13 vmlinuz-3.8-2-amd64

Solution 1:

We see that df claims only 19MB is used in /boot and 151MB is available. But the directory listing shows far more than 19MB of files!

Therefore I would guess that the /boot filesystem has been corrupted.

Unmount it and check it:

umount /boot
fsck -f /boot