Get all installed packages on a non running system

Hi. My Manjaro SSD is not booting anymore.
I tried to follow the instruction to recreate GRUB but it fails so I will set up Manjaro on a new SSD.
I can still access the root partition and all data on it. Is there a way to get a list of all installed packages from this non running partition?
So, that I can use this list to install the same packages on the new SSD.

Each package has an entry in /var/lib/pacman/local/
as a separate subdirectory
and in each one there is a file “descr

The content starts with the keyword %NAME%
and in the next line is the name of the package

for example:

%NAME%
zsh

for

less /var/lib/pacman/local/zsh-5.9-5/desc

How to extract all of them with one command I don’t know.
Something with grep

chroot into the system from a booted live ISO should let you use pacman for that - see the Arch wiki where you’ll find the command to create the list

1 Like

Yes! Boot up from the live USB and chroot into your installed system, and then run these two commands… :point_down:

pacman -Qnq > pkglist-repos.txt
pacman -Qmq > pkglist-foreign.txt

The first of those files will contain a list of all the installed packages from the official Manjaro repos, and the second one will contain a list of all the installed packages from the AUR.

I’m afraid I can’t tell you how to list Snaps or FlatPaks, though — I don’t have either of those installed — but I’m sure there’s a way for that too by using the appropriate tools. :wink:

3 Likes

Fantastic! Thanks! :+1:
I only use native and Arch packages so your suggestions cover all what I need.

1 Like

There is a wiki page for this situation

pacman/Restore local database - ArchWiki

[root tip] [Utililty Script] Backup configuration and package list

2 Likes

I would also advise you to make a backup copy of your /etc directory and its subdirectories, and especially so if you’ve made any changes to system-wide configuration files that you would like to retain, such as for instance if you’ve changed anything under /etc/pam.d, or files like /etc/default/grub, /etc/mkinitcpio.conf and/or /etc/sysctl.d/*.

It’s easier to restore a backup than to have to reconfigure everything by hand. :wink:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.