I have an Ubuntu partition that is unbootable although still mountable, and I'd like to create a newly installed system with the exact same packages as this system. The way to restore the list of packages I assume is to mount the unbootable root partition during a live-usb session and navigate to the
/mnt/var/lib/dpkg/ folder assuming its mounted on
/mnt and perform
sudo dpkg -l --admindir > ~/Packages.list which would produce a list file which could be manipulated to include 2 columns, one for the package name and the second is the word install. Then follow the something similar as the advice in this link. The problem is how to retrieve the apt keys from the unbootable partition.
I have seen many site that show how to backup and restore the apt keys from a bootable OS partition. The way to do this found at this link. There seems to be no information about how to automate the backup of keys from the mounted partition (un-bootable).
In a nutshell I would like to perform
sudo apt-key add ~/Repo.keys in the newly installed system and retrieve all keys for
Repo.keys. How to create this file from an unbootable system is what I need.
Can I just copy the
/etc/apt/trusted.gpg file over to the new system and that's it? Or maybe a way to export the keys to a text file or something?