How should I recreate /var/lib/dpkg/info/* ?

Halvor Raknes

Member
Joined
Apr 19, 2021
Messages
154
Reaction score
15
Credits
1,225
I accidentally deleted /var/lib/dpkg/info/* on Linux Mint 22.1 (Ubuntu 24.04). I have since run apt --fix-broken install, and sudo apt check now reports no problems. However, dpkg --audit reports that almost all installed packages are "missing the list control file in the database, they need to be reinstalled". There are about 2863 installed packages but only 77 .list files remain in /var/lib/dpkg/info. What is the recommended way to regenerate the missing .list files? Is apt reinstall $(dpkg-query ...) the right approach, or is there a better/safer method?
 


Do you have Timeshift snapshots ?

If you do, simply Restore to a snapshot taken prior to the /var/lib/dpkg/info/* deletion
 
What happens when you run an "apt update" on the system, I would think that would re-populate itself as it's only info of package information?
 
What happens when you run an "apt update" on the system, I would think that would re-populate itself as it's only info of package information?
I haven't tried that yet. I've been going up until now with the help from LLMs. First DeepSeek got me into this trouble, now I've been getting help from ChatGPT. It actually recommended I get som advice from real people on this part of the repair rather than simply following its advice…
 
I haven't tried that yet. I've been going up until now with the help from LLMs. First DeepSeek got me into this trouble, now I've been getting help from ChatGPT. It actually recommended I get som advice from real people on this part of the repair rather than simply following its advice…
Can you try running "apt update" and "apt upgrade" from the command-line and see if those run correctly without errors?
 
I followed your suggestion and ran sudo apt upgrade.

The results were encouraging:
  • Before the upgrade I had only 77 .list files in /var/lib/dpkg/info/.
  • After the upgrade I now have 585 .list files, so many package metadata files have been regenerated.
  • sudo apt check now reports no dependency problems.
However, dpkg --audit still reports that many packages are missing their .list files, and sudo dpkg --configure -a fails on these packages:
  • openssh-server
  • rsyslog
  • samba-common
  • smbclient
  • samba-common-bin
The first three all fail with:

installed <package> package post-installation script subprocess returned error exit status 10

The corresponding postinst scripts are present, and openssh-server.postinst ends with exit 0, so the failure appears to come from a command executed within the script rather than an explicit exit 10.

Does this give you any idea what the next step should be?
 
Did you als run "apt update"? Just try running a reinstall on them?
Code:
sudo apt reinstall  openssh-server rsyslog samba-common smbclient samba-common-bin
 
The first three all fail with:

installed <package> package post-installation script subprocess returned error exit status 10

The corresponding postinst scripts are present, and openssh-server.postinst ends with exit 0, so the failure appears to come from a command executed within the script rather than an explicit exit 10.

Does this give you any idea what the next step should be?
Can you share the output?
 
Is this a relevant data?

halvor@halvor-X551MA:~$ sudo apt install --reinstall openssh-server
Reading package lists... Done Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 15 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for openssh-server:amd64 halvor@halvor-X551MA:~$
 
Try running this?
Code:
sudo apt update
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt install --reinstall openssh-server
 
Try running this?
Code:
sudo apt update
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt install --reinstall openssh-server

That didn't work so well:

halvor@halvor-X551MA:~$ sudo apt update
[sudo] password for halvor:
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:2 https://brave-browser-apt-release.s3.brave.com stable InRelease [7 547 B]
Hit:3 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble InRelease
Get:4 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages [34,1 kB]
Get:5 https://brave-browser-apt-release.s3.brave.com stable/main arm64 Packages [34,0 kB]
Get:6 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [869 kB]
Get:7 http://security.ubuntu.com/ubuntu noble-security/main i386 Packages [336 kB]
Get:8 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [194 kB]
Get:9 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [1 185 kB]
Get:10 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [273 kB]
Get:11 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1 194 kB]
Get:12 http://security.ubuntu.com/ubuntu noble-security/universe i386 Packages [819 kB]
Get:13 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [237 kB]
Hit:14 http://no.archive.ubuntu.com/ubuntu noble InRelease
Hit:15 http://no.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:16 http://no.archive.ubuntu.com/ubuntu noble-backports InRelease
Ign:17 https://mirror.accum.se/mirror/linuxmint.com/packages xia InRelease
Hit:18 https://mirror.accum.se/mirror/linuxmint.com/packages xia Release
Fetched 5 310 kB in 4s (1 227 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
23 packages can be upgraded. Run 'apt list --upgradable' to see them.
halvor@halvor-X551MA:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 23 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up openssh-server (1:9.6p1-3ubuntu13.18) ...
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned e
rror exit status 10
Setting up rsyslog (8.2312.0-3ubuntu9.2) ...
info: The user `syslog' is already a member of `adm'.
dpkg: error processing package rsyslog (--configure):
installed rsyslog package post-installation script subprocess returned error ex
it status 10
Setting up samba-common (2:4.19.5+dfsg-4ubuntu9.6) ...
dpkg: error processing package samba-common (--configure):
installed samba-common package post-installation script subprocess returned err
or exit status 10
dpkg: dependency problems prevent configuration of smbclient:
smbclient depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package smbclient (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of samba-common-bin:
samba-common-bin depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package samba-common-bin (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
rsyslog
samba-common
smbclient
samba-common-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)
halvor@halvor-X551MA:~$ sudo dpkg --configure -a
Setting up openssh-server (1:9.6p1-3ubuntu13.18) ...
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 10
Setting up rsyslog (8.2312.0-3ubuntu9.2) ...
info: The user `syslog' is already a member of `adm'.
dpkg: error processing package rsyslog (--configure):
installed rsyslog package post-installation script subprocess returned error exit status 10
Setting up samba-common (2:4.19.5+dfsg-4ubuntu9.6) ...
dpkg: error processing package samba-common (--configure):
installed samba-common package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of smbclient:
smbclient depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package smbclient (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of samba-common-bin:
samba-common-bin depends on samba-common (= 2:4.19.5+dfsg-4ubuntu9.6); however:
Package samba-common is not configured yet.

dpkg: error processing package samba-common-bin (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openssh-server
rsyslog
samba-common
smbclient
samba-common-bin
halvor@halvor-X551MA:~$ sudo apt install --reinstall openssh-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libwayland-server0:i386
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 23 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for openssh-server:amd64
halvor@halvor-X551MA:~$

However, I investigated further.

apt knows the package correctly:
  • apt-cache policy shows the installed and candidate version.
  • apt-cache show contains a valid Filename: pool/...deb.
  • apt-cache madison lists all available versions.
  • The corresponding .deb is already present in /var/cache/apt/archives/.
Yet sudo apt reinstall openssh-server still immediately fails with:
E: Internal Error, No file name for openssh-server:amd64
So it doesn't appear to be a missing repository entry or a missing package archive. Could this be caused by the earlier loss of most of /var/lib/dpkg/info, or is there another apt metadata database that may have become inconsistent?
 
When you delete system files...there's only one fix..reinstall.

This is why it's so important to backup your system with a system image created with Foxclone and Rescuezilla.

I could delete Var...Home or run a command that bricks my system and be up and running in the time it takes to put the image back on the Drive.

The first thing you do after installing the Distro and put everything you like on it...is create a system image and do this once a month...should anything happen which includes Drive failure...you loose nothing.
1784846096578.gif
 
important to backup your system with a system image created with Foxclone and Rescuezilla.
I would add to the above by saying that Timeshift is a good app to have ....because it deals with system files, it would have saved your bacon.
Also, a monthly Foxclone or Rescuezilla image is a life saver as well. I prefer Rescuezilla. It has not let me down.
 
I accidentally deleted /var/lib/dpkg/info/* on Linux Mint 22.1 (Ubuntu 24.04). I have since run apt --fix-broken install, and sudo apt check now reports no problems. However, dpkg --audit reports that almost all installed packages are "missing the list control file in the database, they need to be reinstalled". There are about 2863 installed packages but only 77 .list files remain in /var/lib/dpkg/info. What is the recommended way to regenerate the missing .list files? Is apt reinstall $(dpkg-query ...) the right approach, or is there a better/safer method?
Basically, what needs to happen here is that the packages on the system need to be be re-installed so that the data that is located in the /var/lib/dpkg/info file can be reconstructed during the re-installation process. Something like the following code might be able to do it:
Code:
for pkg in $(dpkg -l | awk '/^ii/ {print $2}'); do sudo apt-get --reinstall -y install "$pkg"; done
That code will note all the packages that are installed, get their names and re-install them. Please note that I haven't had to do this, nor have I run that code, but it is what I would try given this issue. The command would need to be run as root. It would take some time to run.
 
Basically, what needs to happen here is that the packages on the system need to be be re-installed so that the data that is located in the /var/lib/dpkg/info file can be reconstructed during the re-installation process. Something like the following code might be able to do it:
This is what I like better about dnf/rpm as the similar location to this for fedora or rhel would be /var/lib/rpm where the db of rpm informations gets stored. If the db there gets corrupted or something like this you just have a command that rebuilds this information.
 
This is what I like better about dnf/rpm as the similar location to this for fedora or rhel would be /var/lib/rpm where the db of rpm informations gets stored. If the db there gets corrupted or something like this you just have command that rebuilds this information.
It would be very helpful if there was a single command in debian systems to restore the
/var/lib/dpkg/info files, like the "--rebuilddb" option for dnf, but the files in the rpm database and those in /var/lib/dpkg/info, are to some significant degree, not the same sort of files. The files in a debian system function to some degree in a different way than occurs in fedora.

Briefly, without much recent experience in fedora, I think the database basically holds metadata about packages, package file lists, history of package installation, upgrade, removal ... those sorts of things, stored in a binary database format.

In debian, there is a more extensive listing of basically text files which includes the following sorts:
Code:
Plain text list of all files installed by that package (full paths).
MD5 checksums of the package’s files.
List of configuration files provided by the package (usually under /etc).
Maintenance executable scripts for packages such as:
        <pkgname>.preinst - run before installation/upgrade.
        <pkgname>.postinst - run after installation/upgrade (e.g., update caches, start services).
        <pkgname>.prerm - run before removal.
        <pkgname>.postrm - run after removal (cleanup, purge actions).
        <pkgname>.config - used by dpkg-reconfigure for interactive reconfiguration.

Control/metadata files (depending on the package):
        <pkgname>.triggers
        <pkgname>.shlibs
        <pkgname>.symbols
        <pkgname>.emacsen, etc.
There are also a few global files in the same directory, such as: format, which describes the dpkg info directory format version, and md5sums (sometimes) and overall checksums for some dpkg metadata.

The above variety of files in debian can be seen by navigating to /var/lib/dpkg/info and listing the files. The /var/lib/dpkg/info directory holds a lot of diverse files that dpkg uses, and they are largely human readable as text files with scripts or text info and each has a singular separate function. In fedora, the rpm database is largely in a singular binary database format which is not directly readable, and doesn't cover identical ground.

The above differences are reflected in design differences between dpkg & apt compared with rpm & dnf. The apt commands are a family of commands, each of which has it's own separate functionality
Code:
apt                           apt-file                      aptitude-doc-nl               apt-offline-gui
apt-cacher                    apt-forktracer                aptitude-doc-ru               apt-rdepends
apt-cacher-ng                 apticron                      aptitude-robot                apt-show-source
apt-config-auto-update        apticron-systemd              apt-listbugs                  apt-show-versions
apt-config-icons              aptitude                      apt-listchanges               apt-src
apt-config-icons-hidpi        aptitude-common               apt-listdifferences           apt-suggest-auto
apt-config-icons-large        aptitude-doc-cs               aptly                         apt-transport-https
apt-config-icons-large-hidpi  aptitude-doc-en               aptly-api                     apt-transport-oci
apt-cudf                      aptitude-doc-es               aptly-publisher               apt-transport-s3
apt-dater                     aptitude-doc-fi               apt-mirror                    apt-transport-tor
apt-dater-host                aptitude-doc-fr               apt-mirror2                   apt-utils
apt-doc                       aptitude-doc-it               apt-move                      apt-venv
apt-eatmydata                 aptitude-doc-ja               apt-offline                   apt-xapian

The dnf command is more of a singular command that covers its ground by way of sub-commands and options, but is not as extensive as the apt family.

After all of the above, for the original issue, it's clear that the /var/lib/dpkg/info files are vital for proper dpkg functioning on a debian system, so the restoration of the files is really necessary for the system to run as intended.
 
Last edited:
Top