3

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?

Jacques MALAPRADE
  • 945
  • 4
  • 17
  • 35
  • 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

1 Answers1

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.

Keith
  • 185