Ubuntu – Unmet dependencies when trying to update

aptdpkg

Long story short, my Ubuntu 12.04 VM ran out of space and an update failed. I then increased the disk space but am no longer able to update anything using apt-get.

This is the output of apt-get upgrade:

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-headers-generic : Depends: linux-headers-3.2.0-53-generic but it is not installed
 linux-image-generic : Depends: linux-image-3.2.0-53-generic but it is not installed
E: Unmet dependencies. Try using -f.

After that I run apt-get install -f and get this output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-generic linux-headers-generic linux-image-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic
3 upgraded, 0 newly installed, 0 to remove and 57 not upgraded.
3 not fully installed or removed.
Need to get 6448 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 [link removed] precise-updates/main linux-generic amd64 3.2.0.59.70 [1718 B]
Get:2 [link removed] precise-updates/main linux-image-generic amd64 3.2.0.59.70 [2370 B]
Get:3 [link removed] precise-updates/main linux-headers-generic amd64 3.2.0.59.70 [2360 B]
Fetched 6448 B in 0s (40.1 kB/s)           
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:en",
    LC_ALL = (unset),
    LC_TIME = "fi_FI.UTF-8",
    LC_MONETARY = "fi_FI.UTF-8",
    LC_ADDRESS = "fi_FI.UTF-8",
    LC_TELEPHONE = "fi_FI.UTF-8",
    LC_NAME = "fi_FI.UTF-8",
    LC_MEASUREMENT = "fi_FI.UTF-8",
    LC_IDENTIFICATION = "fi_FI.UTF-8",
    LC_NUMERIC = "fi_FI.UTF-8",
    LC_PAPER = "fi_FI.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-53-generic; however:
  Package linux-image-3.2.0-53-generic is not installed.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: dependency problems prevent configuration of linux-headers-generic:
 linux-headers-generic depends on linux-headers-3.2.0-53-generic; however:
  Package linux-headers-3.2.0-53-generic is not installed.
dpkg: error processing linux-headers-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.53.63); however:
  Package linux-image-generic is not configured yet.
 linux-generic depends on linux-headers-generic (= 3.2.0.53.63); however:
  Package linux-headers-generic is not configured yet.
dpkg: error processing linux-generic (--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-image-generic
 linux-headers-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then I tried dpkg --configure -a:

dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-53-generic; however:
  Package linux-image-3.2.0-53-generic is not installed.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.53.63); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-headers-generic:
 linux-headers-generic depends on linux-headers-3.2.0-53-generic; however:
  Package linux-headers-3.2.0-53-generic is not installed.
dpkg: error processing linux-headers-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-generic
 linux-generic
 linux-headers-generic

I'm not that proficient with Linux so I have no idea what to do next. Any help is appreciated. uname -r says 3.2.0-58-generic.

Best Answer

Remove all the three linux-image-generic, linux-generic, linux-headers-generic packages and then run an upgrade.

sudo dpkg -P linux-generic
sudo dpkg -P linux-image-generic
sudo dpkg -P linux-headers-generic
sudo apt-get upgrade