4

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?

closed as off-topic by Braiam, Eric Carvalho, Seth Feb 11 '16 at 4:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This describes a problem that can't be reproduced that seemingly went away on its own or was only relevant to a very specific period of time. It's off-topic as it's unlikely to help future readers." – Braiam, Eric Carvalho, Seth
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I followed the instructions in the links I provided and although there was a few errors concerning Packages/repositories it could not find due to not having the keys and repository locations, the majority was reinstalled under the new system. I then had to individually install keys and packages for those it couldn't find. These are mostly keys such as Ubuntu-tweak and others that aren't part of the ubuntu repositories. My home directory was just restored from a backup using live usb. Not sure if this answers the question I posed previously but it solved my problem. – Jacques MALAPRADE Jan 12 '16 at 10:17
0

Mount the drive from the live-usb session, do chroot /mnt (assuming the drive is mounted at /mnt), followed by the first three lines from this answer (as if the drive were bootable). Depending on the exact directory structure on that drive, you may need to replace ~/ with some directory that you know exists.

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