1

My boot partition is full and I attempted to follow the solution found here: https://askubuntu.com/a/142937/178039

Running:
    dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
linux-headers-3.2.0-23
linux-headers-3.2.0-23-generic
linux-headers-3.2.0-25
linux-headers-3.2.0-25-generic
linux-headers-3.2.0-26
linux-headers-3.2.0-26-generic
linux-headers-3.2.0-27
linux-headers-3.2.0-27-generic
linux-headers-3.2.0-29
linux-headers-3.2.0-29-generic
linux-headers-3.2.0-31
linux-headers-3.2.0-31-generic
linux-headers-3.2.0-32
linux-headers-3.2.0-32-generic
linux-headers-3.2.0-33
linux-headers-3.2.0-33-generic
linux-headers-3.2.0-34
linux-headers-3.2.0-34-generic
linux-headers-3.2.0-35
linux-headers-3.2.0-35-generic
linux-headers-3.2.0-36
linux-headers-3.2.0-36-generic
linux-headers-3.2.0-37
linux-headers-3.2.0-37-generic
linux-headers-3.2.0-38
linux-headers-3.2.0-38-generic
linux-headers-3.2.0-40
linux-headers-3.2.0-40-generic
linux-headers-3.2.0-41
linux-headers-3.2.0-41-generic
linux-image-3.2.0-31-generic
linux-image-3.2.0-32-generic
linux-image-3.2.0-33-generic
linux-image-3.2.0-34-generic
linux-image-3.2.0-35-generic
linux-image-3.2.0-36-generic
linux-image-3.2.0-37-generic
linux-image-3.2.0-38-generic

However, when I run the command sudo apt-get -y purge linux-image-3.2.0-31-generic to remove an older image I get this issue:

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-server : Depends: linux-image-server (= 3.2.0.49.59) but 3.2.0.40.48 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I run sudo apt-get -f install and this just tells me my boot partition is full:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-23-generic linux-headers-3.2.0-31-generic linux-headers-3.2.0-26-generic linux-image-3.2.0-37-generic linux-headers-3.2.0-23 linux-headers-3.2.0-25 linux-headers-3.2.0-31 linux-headers-3.2.0-26
  linux-headers-3.2.0-32 linux-headers-3.2.0-27 linux-headers-3.2.0-33 linux-headers-3.2.0-34 linux-headers-3.2.0-29 linux-headers-3.2.0-36 linux-headers-3.2.0-37 linux-headers-3.2.0-38 linux-headers-3.2.0-34-generic
  linux-headers-3.2.0-29-generic libspeex1 linux-headers-3.2.0-37-generic linux-headers-3.2.0-32-generic linux-headers-3.2.0-27-generic linux-image-3.2.0-38-generic libtheora0 daemon libservlet2.5-java linux-headers-3.2.0-38-generic
  linux-headers-3.2.0-25-generic linux-headers-3.2.0-33-generic linux-headers-3.2.0-36-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-image-3.2.0-49-generic linux-image-server
Suggested packages:
  fdutils linux-doc-3.2.0 linux-source-3.2.0 linux-tools
The following NEW packages will be installed:
  linux-image-3.2.0-49-generic
The following packages will be upgraded:
  linux-image-server
1 upgraded, 1 newly installed, 0 to remove and 113 not upgraded.
7 not fully installed or removed.
Need to get 0 B/38.5 MB of archives.
After this operation, 150 MB of additional disk space will be used.
Do you want to continue [Y/n]?
(Reading database ... 487607 files and directories currently installed.)
Unpacking linux-image-3.2.0-49-generic (from .../linux-image-3.2.0-49-generic_3.2.0-49.75_amd64.deb) ...
Done.
dpkg: error processing /var/cache/apt/archives/linux-image-3.2.0-49-generic_3.2.0-49.75_amd64.deb (--unpack):
 failed in write on buffer copy for backend dpkg-deb during `./boot/vmlinuz-3.2.0-49-generic': No space left on device
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-3.2.0-49-generic_3.2.0-49.75_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Running apt-get autoremove gives the me:

Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-server : Depends: linux-image-server (= 3.2.0.49.59) but 3.2.0.40.48 is installed
E: Unmet dependencies. Try using -f.

It seems I am in a loop. How can I fix this issue to finally upgrade my server? I am on 12.04


Edit 1: When attempting to remove an image on boot: sudo rm /boot/initrd.img-3.2.0-31-generic sudo apt-get -y purge linux-image-3.2.0-31-generic I get:

Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-server : Depends: linux-image-server (= 3.2.0.49.59) but 3.2.0.40.48 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I then try and run apt-get -f install and get this error:

    Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-23-generic linux-headers-3.2.0-31-generic linux-headers-3.2.0-26-generic linux-image-3.2.0-37-generic linux-headers-3.2.0-23 linux-headers-3.2.0-25 linux-headers-3.2.0-31 linux-headers-3.2.0-26
  linux-headers-3.2.0-32 linux-headers-3.2.0-27 linux-headers-3.2.0-33 linux-headers-3.2.0-34 linux-headers-3.2.0-29 linux-headers-3.2.0-36 linux-headers-3.2.0-37 linux-headers-3.2.0-38 linux-headers-3.2.0-34-generic
  linux-headers-3.2.0-29-generic libspeex1 linux-headers-3.2.0-37-generic linux-headers-3.2.0-32-generic linux-headers-3.2.0-27-generic linux-image-3.2.0-38-generic libtheora0 daemon libservlet2.5-java linux-headers-3.2.0-38-generic
  linux-headers-3.2.0-25-generic linux-headers-3.2.0-33-generic linux-headers-3.2.0-36-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-image-server
The following packages will be upgraded:
  linux-image-server
1 upgraded, 0 newly installed, 0 to remove and 113 not upgraded.
5 not fully installed or removed.
Need to get 0 B/2,370 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]?
Setting up linux-image-3.2.0-40-generic (3.2.0-40.64) ...
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-49-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.2.0-40-generic /boot/vmlinuz-3.2.0-40-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-40-generic /boot/vmlinuz-3.2.0-40-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-40-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-40-generic /boot/vmlinuz-3.2.0-40-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-40-generic /boot/vmlinuz-3.2.0-40-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-49-generic
Found linux image: /boot/vmlinuz-3.2.0-41-generic
Found linux image: /boot/vmlinuz-3.2.0-40-generic
Found initrd image: /boot/initrd.img-3.2.0-40-generic
Found linux image: /boot/vmlinuz-3.2.0-39-generic
Found initrd image: /boot/initrd.img-3.2.0-39-generic
Found linux image: /boot/vmlinuz-3.2.0-38-generic
Found initrd image: /boot/initrd.img-3.2.0-38-generic
Found linux image: /boot/vmlinuz-3.2.0-37-generic
Found initrd image: /boot/initrd.img-3.2.0-37-generic
Found linux image: /boot/vmlinuz-3.2.0-36-generic
Found initrd image: /boot/initrd.img-3.2.0-36-generic
Found linux image: /boot/vmlinuz-3.2.0-35-generic
Found initrd image: /boot/initrd.img-3.2.0-35-generic
Found linux image: /boot/vmlinuz-3.2.0-34-generic
Found linux image: /boot/vmlinuz-3.2.0-33-generic
Found linux image: /boot/vmlinuz-3.2.0-32-generic
Found linux image: /boot/vmlinuz-3.2.0-31-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up linux-image-3.2.0-41-generic (3.2.0-41.66) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.2.0-41-generic /boot/vmlinuz-3.2.0-41-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-41-generic /boot/vmlinuz-3.2.0-41-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-41-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-41-generic /boot/vmlinuz-3.2.0-41-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-41-generic /boot/vmlinuz-3.2.0-41-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-49-generic
Found linux image: /boot/vmlinuz-3.2.0-41-generic
Found initrd image: /boot/initrd.img-3.2.0-41-generic
Found linux image: /boot/vmlinuz-3.2.0-40-generic
Found initrd image: /boot/initrd.img-3.2.0-40-generic
Found linux image: /boot/vmlinuz-3.2.0-39-generic
Found initrd image: /boot/initrd.img-3.2.0-39-generic
Found linux image: /boot/vmlinuz-3.2.0-38-generic
Found initrd image: /boot/initrd.img-3.2.0-38-generic
Found linux image: /boot/vmlinuz-3.2.0-37-generic
Found initrd image: /boot/initrd.img-3.2.0-37-generic
Found linux image: /boot/vmlinuz-3.2.0-36-generic
Found initrd image: /boot/initrd.img-3.2.0-36-generic
Found linux image: /boot/vmlinuz-3.2.0-35-generic
Found initrd image: /boot/initrd.img-3.2.0-35-generic
Found linux image: /boot/vmlinuz-3.2.0-34-generic
Found linux image: /boot/vmlinuz-3.2.0-33-generic
Found linux image: /boot/vmlinuz-3.2.0-32-generic
Found linux image: /boot/vmlinuz-3.2.0-31-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up linux-image-3.2.0-49-generic (3.2.0-49.75) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-49-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-49-generic /boot/vmlinuz-3.2.0-49-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-49-generic
Found initrd image: /boot/initrd.img-3.2.0-49-generic
Found linux image: /boot/vmlinuz-3.2.0-41-generic
Found initrd image: /boot/initrd.img-3.2.0-41-generic
Found linux image: /boot/vmlinuz-3.2.0-40-generic
Found initrd image: /boot/initrd.img-3.2.0-40-generic
Found linux image: /boot/vmlinuz-3.2.0-39-generic
Found initrd image: /boot/initrd.img-3.2.0-39-generic
Found linux image: /boot/vmlinuz-3.2.0-38-generic
Found initrd image: /boot/initrd.img-3.2.0-38-generic
Found linux image: /boot/vmlinuz-3.2.0-37-generic
Found initrd image: /boot/initrd.img-3.2.0-37-generic
Found linux image: /boot/vmlinuz-3.2.0-36-generic
Found initrd image: /boot/initrd.img-3.2.0-36-generic
Found linux image: /boot/vmlinuz-3.2.0-35-generic
Found initrd image: /boot/initrd.img-3.2.0-35-generic
Found linux image: /boot/vmlinuz-3.2.0-34-generic
Found linux image: /boot/vmlinuz-3.2.0-33-generic
Found linux image: /boot/vmlinuz-3.2.0-32-generic
Found linux image: /boot/vmlinuz-3.2.0-31-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up linux-image-server (3.2.0.40.48) ...
dpkg: dependency problems prevent configuration of linux-server:
 linux-server depends on linux-image-server (= 3.2.0.49.59); however:
  Version of linux-image-server on system is 3.2.0.40.48.
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.
                                                                                                          Errors were encountered while processing:
 linux-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
joshmmo
  • 113
  • 1
  • 5

2 Answers2

1

In all the error output you provided there's one important part: No space left on device. This indicates that your disk is full. A full disk can lead to packages left in an unconfigured state, resulting in the dependency errors you're seeing.

The only sane thing here is to free up some space. For example, manually remove the initrd image:

sudo rm /boot/initrd.img-3.2.0-31-generic

try sudo apt-get -f install again, then purge the package

sudo apt-get -y purge linux-image-3.2.0-31-generic

If you get another No space left on device remove one more initrd.img and try again.

gertvdijk
  • 67,947
Eric Carvalho
  • 54,385
  • I try to run purge after removing the file and get: The following packages have unmet dependencies: linux-server : Depends: linux-image-server (= 3.2.0.49.59) but 3.2.0.40.48 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). When I try and run apt-get -f install I get another long error I will have to put in the question to fit. – joshmmo Jul 24 '13 at 18:56
  • @joshmmo Run apt-get update and check the directory /var/lib/apt/lists/partial/. If there is any file in there, it means apt-get update didn't complete successfully. Keep running apt-get update until you get an empty /var/lib/apt/lists/partial/, then run apt-get -f install again. – Eric Carvalho Jul 24 '13 at 19:46
  • @EricCarvalho I don't see why removing a file on the filesystem (which belongs to a package and you should not remove manually anyway!) will solve the conflict state of the DPKG/APT database. – gertvdijk Jul 24 '13 at 20:23
  • @EricCarvalho The directory is empty. I ran apt-get -f install again and it worked. – joshmmo Jul 24 '13 at 21:07
  • 2
    @gertvdijk The bigger problem here was not the unmet dependencies, it was a full /boot partition. I told the OP to remove that file to free up some space so the package linux-image-3.2.0-49-generic could be properly installed. The file I told him to remove is part of a package he was trying to remove, so its presence is irrelevant. As you can see in the OP's last command his problem was solved. This question may be duped to a "/boot full" one, but it's not a "How do I resolve unmet dependencies" duplicate. – Eric Carvalho Jul 24 '13 at 23:03
  • @EricCarvalho Ah! I didn't see that in all the error output. I've included that part in your answer. However, the user should first try to free up space by removing user files, avoiding the removal of files part of packages. – gertvdijk Jul 24 '13 at 23:20
  • @gertvdijk Not sure I understand why I would remove user files when my /boot partition was full. – joshmmo Jul 25 '13 at 16:28
-1

Try the following command:

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get -y purge
vineet
  • 11
  • 1
    Why would one run this obscure and possibly harmful command? sudo apt-get -y purge will remove stuff thoroughly without asking for confirmation! See also http://askubuntu.com/a/244739/88802 – gertvdijk Jan 03 '14 at 09:12