Ubuntu Dpkg: unrecoverable fatal error

From richud.com
Jump to navigation Jump to search

dpkg, the nasty error

Scenario, you run apt-get update and it all goes pear shaped!

There will probably be a series of errors like "dpkg: warning: files list file for package `xxxxxxxxxxx' missing, assuming package has no files currently installed.", culminating in this;

(Reading database ... 55%dpkg: unrecoverable fatal error, aborting:
 files list file for package `linux-headers-3.2.0-31-generic' contains empty filename
E: Sub-process /usr/bin/dpkg returned an error code (2)

See what the package erroring above is, in this case `linux-headers-3.2.0-31-generic'.

Fix /var/lib/dpkg/status

  • Remove the entire section given in error above, in this case `linux-headers-3.2.0-31-generic' from the 'status' file (cntrl-K to delete the lines in nano).

i.e. the line starting Package: to the line above the next Package: line. e.g. All the below.


$ sudo nano -w /var/lib/dpkg/status

#Remove this

Package: linux-headers-3.2.0-31-generic
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 10968
Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
Architecture: amd64
Source: linux
Version: 3.2.0-31.50
Provides: linux-headers, linux-headers-3.0
Depends: linux-headers-3.2.0-31, libc6 (>= 2.14)
Description: Linux kernel headers for version 3.2.0 on 64 bit x86 SMP
 This package provides kernel header files for version 3.2.0 on
 64 bit x86 SMP.
 .
 This is for sites that want the latest kernel headers.  Please read
 /usr/share/doc/linux-headers-3.2.0-31/debian.README.gz for details.

Fix apt-get

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-headers-3.2.0-31-generic
The following NEW packages will be installed
  linux-headers-3.2.0-31-generic
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 983 kB of archives.
After this operation, 11.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

You should then get still the initial errors "dpkg: warning: files list file for package `xxxxxxxxxxx' missing, assuming package has no files currently installed.", but it should install the problem package ok, viz `linux-headers-3.2.0-31-generic'.

Now run

$ sudo apt-get dist-upgrade

Yet again you should see "dpkg: warning: files list file for package `xxxxxxxxxxx' missing, assuming package has no files currently installed.".

Now do this replacing xxxxxxx with all the package names above that appear.

sudo apt-get install --reinstall xxxxxxxxxx

They should all now reinstall without a problem and you are good to go, problem now fixed! (at least mine was)