Cannot install packages (/var/lib/dpkg/status no such file or directory)

Asked by Paul Schreiber

Here are the answers from PackageManagerTroubleshootingProcedure
https://help.ubuntu.com/community/PackageManagerTroubleshootingProcedure

root@green:~# sudo grep -R proxy /etc/apt/*
root@green:~#
root@green:~# sudo fuser -vvv /var/lib/dpkg/lock
root@green:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.10
DISTRIB_CODENAME=quantal
DISTRIB_DESCRIPTION="Ubuntu 12.10"
root@green:~# uname -a
Linux green 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
root@green:~# sudo rm /var/lib/apt/lists/lock
root@green:~#
root@green:~# sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
root@green:~#
root@green:~# sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
cp: cannot stat `/var/lib/dpkg/status-old': No such file or directory
root@green:~#
root@green:~# sudo mv /var/lib/dpkg/available /var/lib/dpkg/available-bad
root@green:~#
root@green:~# sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
cp: cannot stat `/var/lib/dpkg/available-old': No such file or directory
root@green:~#
root@green:~# sudo rm -rf /var/lib/dpkg/updates/*
root@green:~#
root@green:~# sudo rm -rf /var/lib/apt/lists
root@green:~#
root@green:~# sudo rm /var/cache/apt/*.bin
root@green:~#
root@green:~# sudo mkdir /var/lib/apt/lists
root@green:~#
root@green:~# sudo mkdir /var/lib/apt/lists/partial
root@green:~#
root@green:~# LANG=C;sudo apt-get clean
root@green:~#
root@green:~# LANG=C;sudo apt-get autoclean
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# LANG=C;sudo apt-get --purge autoremove
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# LANG=C;sudo apt-get update -o APT::Cache-Limit=100000000
Ign http://dl.google.com stable InRelease
Ign http://dl.google.com stable InRelease
Get:1 http://dl.google.com stable Release.gpg [198 B]
Ign http://security.ubuntu.com quantal-security InRelease
Get:2 http://dl.google.com stable Release.gpg [198 B]
Get:3 http://security.ubuntu.com quantal-security Release.gpg [933 B]
Get:4 http://dl.google.com stable Release [1,350 B]
Get:5 http://dl.google.com stable Release [1,341 B]
Get:6 http://security.ubuntu.com quantal-security Release [49.6 kB]
Get:7 http://dl.google.com stable/main amd64 Packages [657 B]
Get:8 http://dl.google.com stable/main i386 Packages [659 B]
Get:9 http://dl.google.com stable/main amd64 Packages [469 B]
Get:10 http://dl.google.com stable/main i386 Packages [486 B]
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Get:11 http://security.ubuntu.com quantal-security/main Sources [6,018 B]
Get:12 http://security.ubuntu.com quantal-security/restricted Sources [14 B]
Get:13 http://security.ubuntu.com quantal-security/universe Sources [1,457 B]
Get:14 http://security.ubuntu.com quantal-security/multiverse Sources [14 B]
Get:15 http://security.ubuntu.com quantal-security/main amd64 Packages [27.6 kB]
Get:16 http://security.ubuntu.com quantal-security/restricted amd64 Packages [14 B]
Get:17 http://security.ubuntu.com quantal-security/universe amd64 Packages [5,042 B]
Get:18 http://security.ubuntu.com quantal-security/multiverse amd64 Packages [14 B]
Get:19 http://security.ubuntu.com quantal-security/main i386 Packages [27.7 kB]
Get:20 http://security.ubuntu.com quantal-security/restricted i386 Packages [14 B]
Get:21 http://security.ubuntu.com quantal-security/universe i386 Packages [5,060 B]
Get:22 http://security.ubuntu.com quantal-security/multiverse i386 Packages [14 B]
Get:23 http://security.ubuntu.com quantal-security/main Translation-en [10.5 kB]
Get:24 http://security.ubuntu.com quantal-security/multiverse Translation-en [14 B]
Get:25 http://security.ubuntu.com quantal-security/restricted Translation-en [14 B]
Get:26 http://security.ubuntu.com quantal-security/universe Translation-en [3,150 B]
Ign http://ubuntu.mirror.iweb.ca quantal InRelease
Ign http://ubuntu.mirror.iweb.ca quantal-updates InRelease
Get:27 http://ubuntu.mirror.iweb.ca quantal Release.gpg [933 B]
Get:28 http://ubuntu.mirror.iweb.ca quantal-updates Release.gpg [933 B]
Get:29 http://ubuntu.mirror.iweb.ca quantal Release [49.6 kB]
Get:30 http://ubuntu.mirror.iweb.ca quantal-updates Release [49.6 kB]
Get:31 http://ubuntu.mirror.iweb.ca quantal/main Sources [872 kB]
Ign http://security.ubuntu.com quantal-security/main Translation-en_US
Ign http://security.ubuntu.com quantal-security/multiverse Translation-en_US
Ign http://security.ubuntu.com quantal-security/restricted Translation-en_US
Ign http://security.ubuntu.com quantal-security/universe Translation-en_US
Get:32 http://ubuntu.mirror.iweb.ca quantal/restricted Sources [5,646 B]
Get:33 http://ubuntu.mirror.iweb.ca quantal/universe Sources [5,522 kB]
Get:34 http://ubuntu.mirror.iweb.ca quantal/multiverse Sources [166 kB]
Get:35 http://ubuntu.mirror.iweb.ca quantal/main amd64 Packages [1,137 kB]
Get:36 http://ubuntu.mirror.iweb.ca quantal/restricted amd64 Packages [8,369 B]
Get:37 http://ubuntu.mirror.iweb.ca quantal/universe amd64 Packages [5,274 kB]
Get:38 http://ubuntu.mirror.iweb.ca quantal/multiverse amd64 Packages [131 kB]
Get:39 http://ubuntu.mirror.iweb.ca quantal/main i386 Packages [1,136 kB]
Get:40 http://ubuntu.mirror.iweb.ca quantal/restricted i386 Packages [8,387 B]
Get:41 http://ubuntu.mirror.iweb.ca quantal/universe i386 Packages [5,285 kB]
Get:42 http://ubuntu.mirror.iweb.ca quantal/multiverse i386 Packages [133 kB]
Get:43 http://ubuntu.mirror.iweb.ca quantal/main Translation-en [660 kB]
Get:44 http://ubuntu.mirror.iweb.ca quantal/multiverse Translation-en [100 kB]
Get:45 http://ubuntu.mirror.iweb.ca quantal/restricted Translation-en [2,575 B]
Get:46 http://ubuntu.mirror.iweb.ca quantal/universe Translation-en [3,648 kB]
Get:47 http://ubuntu.mirror.iweb.ca quantal-updates/main Sources [14.2 kB]
Get:48 http://ubuntu.mirror.iweb.ca quantal-updates/restricted Sources [14 B]
Get:49 http://ubuntu.mirror.iweb.ca quantal-updates/universe Sources [4,282 B]
Get:50 http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Sources [14 B]
Get:51 http://ubuntu.mirror.iweb.ca quantal-updates/main amd64 Packages [46.7 kB]
Get:52 http://ubuntu.mirror.iweb.ca quantal-updates/restricted amd64 Packages [14 B]
Get:53 http://ubuntu.mirror.iweb.ca quantal-updates/universe amd64 Packages [19.9 kB]
Get:54 http://ubuntu.mirror.iweb.ca quantal-updates/multiverse amd64 Packages [14 B]
Get:55 http://ubuntu.mirror.iweb.ca quantal-updates/main i386 Packages [46.7 kB]
Get:56 http://ubuntu.mirror.iweb.ca quantal-updates/restricted i386 Packages [14 B]
Get:57 http://ubuntu.mirror.iweb.ca quantal-updates/universe i386 Packages [20.0 kB]
Get:58 http://ubuntu.mirror.iweb.ca quantal-updates/multiverse i386 Packages [14 B]
Get:59 http://ubuntu.mirror.iweb.ca quantal-updates/main Translation-en [21.5 kB]
Get:60 http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Translation-en [14 B]
Get:61 http://ubuntu.mirror.iweb.ca quantal-updates/restricted Translation-en [14 B] c
Get:62 http://ubuntu.mirror.iweb.ca quantal-updates/universe Translation-en [10.3 kB]
Ign http://ubuntu.mirror.iweb.ca quantal/main Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal/multiverse Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal/restricted Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal/universe Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/main Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/restricted Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/universe Translation-en_US
Fetched 24.5 MB in 1min 15s (326 kB/s)
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# sudo dpkg --configure -a
dpkg: error: failed to open package info file `/var/lib/dpkg/status' for reading: No such file or directory
root@green:~# sudo dpkg --clear-avail
root@green:~#
root@green:~# LANG=C;sudo apt-get -f install
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# LANG=C;sudo apt-get --fix-missing install
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# LANG=C;sudo apt-get update -o APT::Cache-Limit=100000000 && sudo apt-get dist-upgrade
Ign http://ubuntu.mirror.iweb.ca quantal InRelease
Ign http://ubuntu.mirror.iweb.ca quantal-updates InRelease
Ign http://dl.google.com stable InRelease
Hit http://ubuntu.mirror.iweb.ca quantal Release.gpg
Hit http://ubuntu.mirror.iweb.ca quantal-updates Release.gpg
Hit http://ubuntu.mirror.iweb.ca quantal Release
Ign http://dl.google.com stable InRelease
Hit http://ubuntu.mirror.iweb.ca quantal-updates Release
Hit http://ubuntu.mirror.iweb.ca quantal/main Sources
Hit http://ubuntu.mirror.iweb.ca quantal/restricted Sources
Hit http://ubuntu.mirror.iweb.ca quantal/universe Sources
Hit http://ubuntu.mirror.iweb.ca quantal/multiverse Sources
Hit http://ubuntu.mirror.iweb.ca quantal/main amd64 Packages
Ign http://security.ubuntu.com quantal-security InRelease
Hit http://ubuntu.mirror.iweb.ca quantal/restricted amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal/universe amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal/multiverse amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal/main i386 Packages
Hit http://ubuntu.mirror.iweb.ca quantal/restricted i386 Packages
Hit http://security.ubuntu.com quantal-security Release.gpg
Hit http://ubuntu.mirror.iweb.ca quantal/universe i386 Packages
Hit http://ubuntu.mirror.iweb.ca quantal/multiverse i386 Packages
Hit http://dl.google.com stable Release.gpg
Hit http://ubuntu.mirror.iweb.ca quantal/main Translation-en
Hit http://dl.google.com stable Release.gpg
Hit http://security.ubuntu.com quantal-security Release
Hit http://ubuntu.mirror.iweb.ca quantal/multiverse Translation-en
Hit http://ubuntu.mirror.iweb.ca quantal/restricted Translation-en
Hit http://dl.google.com stable Release
Hit http://ubuntu.mirror.iweb.ca quantal/universe Translation-en
Hit http://ubuntu.mirror.iweb.ca quantal-updates/main Sources
Hit http://security.ubuntu.com quantal-security/main Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/restricted Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/universe Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/main amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/restricted amd64 Packages
Hit http://security.ubuntu.com quantal-security/restricted Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/universe amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/multiverse amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/main i386 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/restricted i386 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/universe i386 Packages
Hit http://security.ubuntu.com quantal-security/universe Sources
Hit http://ubuntu.mirror.iweb.ca quantal-updates/multiverse i386 Packages
Hit http://dl.google.com stable Release
Hit http://dl.google.com stable/main amd64 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/main Translation-en
Hit http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Translation-en
Hit http://security.ubuntu.com quantal-security/multiverse Sources
Hit http://dl.google.com stable/main i386 Packages
Hit http://ubuntu.mirror.iweb.ca quantal-updates/restricted Translation-en
Hit http://ubuntu.mirror.iweb.ca quantal-updates/universe Translation-en
Hit http://security.ubuntu.com quantal-security/main amd64 Packages
Hit http://dl.google.com stable/main amd64 Packages
Hit http://dl.google.com stable/main i386 Packages
Hit http://security.ubuntu.com quantal-security/restricted amd64 Packages
Hit http://security.ubuntu.com quantal-security/universe amd64 Packages
Hit http://security.ubuntu.com quantal-security/multiverse amd64 Packages
Hit http://security.ubuntu.com quantal-security/main i386 Packages
Ign http://ubuntu.mirror.iweb.ca quantal/main Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal/multiverse Translation-en_US
Hit http://security.ubuntu.com quantal-security/restricted i386 Packages
Ign http://ubuntu.mirror.iweb.ca quantal/restricted Translation-en_US
Hit http://security.ubuntu.com quantal-security/universe i386 Packages
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Hit http://security.ubuntu.com quantal-security/multiverse i386 Packages
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Hit http://security.ubuntu.com quantal-security/main Translation-en
Hit http://security.ubuntu.com quantal-security/multiverse Translation-en
Hit http://security.ubuntu.com quantal-security/restricted Translation-en
Hit http://security.ubuntu.com quantal-security/universe Translation-en
Ign http://ubuntu.mirror.iweb.ca quantal/universe Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/main Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/multiverse Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/restricted Translation-en_US
Ign http://ubuntu.mirror.iweb.ca quantal-updates/universe Translation-en_US
Ign http://security.ubuntu.com quantal-security/main Translation-en_US
Ign http://security.ubuntu.com quantal-security/multiverse Translation-en_US
Ign http://security.ubuntu.com quantal-security/restricted Translation-en_US
Ign http://security.ubuntu.com quantal-security/universe Translation-en_US
Reading package lists... Error!
E: Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@green:~#
root@green:~# find /etc/apt -name '*.list' -exec bash -c 'echo -e "\n$1\n"; cat -n "$1"' _ '{}' \;

/etc/apt/sources.list

     1 # deb http://ubuntu.mirror.iweb.ca/ intrepid main restricted
     2 # deb http://ubuntu.mirror.iweb.ca/ intrepid-updates main restricted
     3 # deb http://security.ubuntu.com/ubuntu intrepid-security main restricted
     4 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
     5 # newer versions of the distribution.
     6
     7 deb http://ubuntu.mirror.iweb.ca/ quantal main restricted
     8 deb-src http://ubuntu.mirror.iweb.ca/ quantal main restricted
     9
    10 ## Major bug fix updates produced after the final release of the
    11 ## distribution.
    12 deb http://ubuntu.mirror.iweb.ca/ quantal-updates main restricted
    13 deb-src http://ubuntu.mirror.iweb.ca/ quantal-updates main restricted
    14
    15 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    16 ## team. Also, please note that software in universe WILL NOT receive any
    17 ## review or updates from the Ubuntu security team.
    18 deb http://ubuntu.mirror.iweb.ca/ quantal universe
    19 deb-src http://ubuntu.mirror.iweb.ca/ quantal universe
    20 deb http://ubuntu.mirror.iweb.ca/ quantal-updates universe
    21 deb-src http://ubuntu.mirror.iweb.ca/ quantal-updates universe
    22
    23 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    24 ## team, and may not be under a free licence. Please satisfy yourself as to
    25 ## your rights to use the software. Also, please note that software in
    26 ## multiverse WILL NOT receive any review or updates from the Ubuntu
    27 ## security team.
    28 deb http://ubuntu.mirror.iweb.ca/ quantal multiverse
    29 deb-src http://ubuntu.mirror.iweb.ca/ quantal multiverse
    30 deb http://ubuntu.mirror.iweb.ca/ quantal-updates multiverse
    31 deb-src http://ubuntu.mirror.iweb.ca/ quantal-updates multiverse
    32
    33 ## Uncomment the following two lines to add software from the 'backports'
    34 ## repository.
    35 ## N.B. software from this repository may not have been tested as
    36 ## extensively as that contained in the main release, although it includes
    37 ## newer versions of some applications which may provide useful features.
    38 ## Also, please note that software in backports WILL NOT receive any review
    39 ## or updates from the Ubuntu security team.
    40 # deb http://ubuntu.mirror.iweb.ca/ intrepid-backports main restricted universe multiverse
    41 # deb-src http://ubuntu.mirror.iweb.ca/ intrepid-backports main restricted universe multiverse
    42
    43 ## Uncomment the following two lines to add software from Canonical's
    44 ## 'partner' repository. This software is not part of Ubuntu, but is
    45 ## offered by Canonical and the respective vendors as a service to Ubuntu
    46 ## users.
    47 # deb http://archive.canonical.com/ubuntu intrepid partner
    48 # deb-src http://archive.canonical.com/ubuntu intrepid partner
    49
    50 deb http://security.ubuntu.com/ubuntu quantal-security main restricted
    51 deb-src http://security.ubuntu.com/ubuntu quantal-security main restricted
    52 deb http://security.ubuntu.com/ubuntu quantal-security universe
    53 deb-src http://security.ubuntu.com/ubuntu quantal-security universe
    54 deb http://security.ubuntu.com/ubuntu quantal-security multiverse
    55 deb-src http://security.ubuntu.com/ubuntu quantal-security multiverse
    56
    57
    58 # deb http://ppa.launchpad.net/a.kurtz/ppa/ubuntu karmic main # disabled on upgrade to karmic
    59 # deb-src http://ppa.launchpad.net/a.kurtz/ppa/ubuntu karmic main # disabled on upgrade to karmic
    60
    61 # deb http://apt.brightbox.net hardy main
    62 # deb http://apt.brightbox.net intrepid main # disabled on upgrade to karmic
    63 # deb http://archive.canonical.com/ lucid partner
    64 # deb http://apt.brightbox.net lucid main
    65

/etc/apt/sources.list.d/mod-spdy.list

     1 ### THIS FILE IS AUTOMATICALLY CONFIGURED ###
     2 # You may comment out this entry, but any other modifications may be lost.
     3 deb http://dl.google.com/linux/mod-spdy/deb/ stable main

/etc/apt/sources.list.d/mod-pagespeed.list

     1 ### THIS FILE IS AUTOMATICALLY CONFIGURED ###
     2 # You may comment out this entry, but any other modifications may be lost.
     3 deb http://dl.google.com/linux/mod-pagespeed/deb/ stable main
root@green:~#

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu apt Edit question
Assignee:
No assignee Edit question
Solved by:
Paul Schreiber
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

ls /var/lib/dpkg

Thanks

Revision history for this message
Paul Schreiber (paulschreiber) said :
#2

paul@green:~$ ls /var/lib/dpkg
alternatives available-bad diversions-old lock statoverride-old
arch cmethopt format parts triggers
available diversions info statoverride updates

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

Did you upgrade from Intrepid directly to Quantal or did you upgrade to each release in turn?

Revision history for this message
Paul Schreiber (paulschreiber) said :
#4

I upgraded from 12.04 to 12.10 this week. The ssh connection died during the install, and I tried to resume. Then rebooting failed, and I had to boot in recovery mode. I believe the status file got lost / corrupted during this upgrade.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

ok and what is output of:

ls /var/backups

Thanks

Revision history for this message
Paul Schreiber (paulschreiber) said :
#6

paul@green:~$ ls /var/backups
apt.extended_states.0 aptitude.pkgstates.0 dpkg.status.0 group.bak
apt.extended_states.1.gz aptitude.pkgstates.1.gz dpkg.status.1.gz gshadow.bak
apt.extended_states.2.gz aptitude.pkgstates.2.gz dpkg.status.2.gz infodir.bak
apt.extended_states.3.gz aptitude.pkgstates.3.gz dpkg.status.3.gz passwd.bak
apt.extended_states.4.gz aptitude.pkgstates.4.gz dpkg.status.4.gz shadow.bak
apt.extended_states.5.gz aptitude.pkgstates.5.gz dpkg.status.5.gz
apt.extended_states.6.gz aptitude.pkgstates.6.gz dpkg.status.6.gz

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#7

ok try:

sudo cp /var/backups/apt.extended_states.0 /var/lib/dpkg/status
sudo apt-get update

Is it now smooth?

Revision history for this message
Paul Schreiber (paulschreiber) said :
#8

Amazing. Yes, thanks.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#9

You'd have been booting to liveCD and copying one from there if it wasn't