1

From a Live USB, and without using the installed Ubuntu's programs like dpkg, dpkg-query, dselect, aptitude, apt-get, or any other (as they are all broken Illegal instruction), how do I read the package lists that apt reads, as a list in order to catalogue the installed packages, to reinstall later?

Reading package lists... Done
Building dependency tree
Reading state information... Done

where is local package database? is almost a perfect answer:

/var/lib/dpkg/status is modified by dpkg if you change the state of a package, i.e. install it, remove it, mark it for some action, ...

  • I don't want just to list "changed" packages, but also depended packages, the entire state of the system, etc. Is that contained by dpkg/status?

    • On another healthy system, that file has ~3800 Package: entries; on the target system it has 3600 Package: entries, and on the Live USB it has only 2000 entries. That sounds right except I worry it doesn't list all the packages.
  • I am not looking for the downloaded .deb cache, nor the cache for dpkg / apt which holds temporary data files -- these do not give the full system state.

  • /var/lib/apt/lists seems to contain a list of package sources and packages, which is almost perfect except a lot of parsing is involved in getting a list of package names from it. Is this the best option?

The file /var/cache/apt/pkgcache.bin exists but since it's a generated binary, I don't think copying it to a fresh install will be sufficient.

2

See man dpkg:

The other files listed below are in their default directories, see option --admindir to see how to change locations of these files.

  • /var/lib/dpkg/available List of available packages.

  • /var/lib/dpkg/status Statuses of available packages.

    This file contains information about whether a package is marked for removing or not, whether it is installed or not, etc. See section INFORMATION ABOUT PACKAGES for more info. The status file is backed up daily in /var/backups. It can be useful if it's lost or corrupted due to filesystems troubles.

You can quit worrying. If the package isn't in status, dpkg doesn't know about it. At all.


By the way, the "package lists" that apt is taking about is a different thing: those are the lists it downloaded from the sources in /etc/apt/sources.list, etc. and are in /var/lib/apt/lists. These contain information about packages in the repositories, and have nothing about the local system.


About your current problem, you can use the live system's dpkg to read that file, using the --admindir option mentioned above.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.