share
Unix & Linuxwhere does apt or dpkg store the list of installed packages?
[+6] [1] Jistanidiot
[2020-04-15 01:52:08]
[ ubuntu apt dpkg ]
[ https://unix.stackexchange.com/questions/580121/where-does-apt-or-dpkg-store-the-list-of-installed-packages ]

I know I can do

dpkg --get-selections

to see a list of installed packages. However I have a hard drive that doesn't boot but most files appear to be intact. Is there a way I can get the list of packages that were installed off this broken hard drive without figuring out how to boot a system from it? Where does dpkg store this information?

The old system was Ubuntu 18.04 LTS.

Thanks in advance.

If you have mounted the old drive, it may be possible to use the --root option to run dpkg commands on the broken system directly ex. dpkg --root=/mnt/oldroot --get-selections - steeldriver
@steeldriver please make this an answer so I can mark it as the solution. Thanks! - Jistanidiot
[+8] [2020-04-15 02:15:56] steeldriver [ACCEPTED]

The answer to your question is that it is stored in the file /var/lib/dpkg/status (at least by default).

However, if you have mounted the old system, then it may be possible to run dpkg --get-selections on it directly, using the --root switch. From man dpkg:

   --root=dir
          Changing  root  changes  instdir  to  «dir»  and   admindir   to
          «dir/var/lib/dpkg».

So for example

dpkg --root=/mnt/oldroot --get-selections

If your old system had a separate /var or /var/lib partition, these will also need to be appropriately mounted as well.


1