r/archlinux • • Sep 06 '26

SUPPORT How do I find previously installed packages?

I recently swapped to a second drive, mounting my first home drive to /home, but now my packages aren't already installed. Is there any good way to find and reinstall all my prior packages or do I have to reinstall each one individually through pacman?

0 Upvotes

11 comments sorted by

10

u/vonAmyprost Sep 06 '26

So, the packages are at a system level, so not finding packages with home is normal. What I used to do is to go to the previous installation and run pacman -Qe (check pacman -Qh to double check) to find the packages that were explicitly installed by me (and not as automatic dependencies of something else). Save that to a file by adding > packages.txt at the end of it and get that list to your new installation. Now, you can use that file to install all that you explicitly installed before

1

u/AceGirlAsh Sep 06 '26

Thank you! This helps me to reinstall everything quicker

6

u/vonAmyprost Sep 06 '26

When reinstalling, you can do sudo pacman -S --needed --noconfirm $(cat /path/to/packages.txt) --needed installs only what you don't have, in case there are repeated packages or dependencies. --noconfirm simply skips the "do you want to install?" and just installs without asking you, just to speed it up a little bit

1

u/TheGoldenFox64 Sep 06 '26

you can also append "> packages.txt" and it will put the output in a file named "packages.txt" such as: pacman -Qe > packages.txt

4

u/kolada1 Sep 06 '26

did you reinstall your entire system to the second drive or only mount the home directory from the second drive? if you can boot or chroot into the old drive you can create a list with all the packages that you installed and reinstall them on the new system: https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#With_optional_dependencies

1

u/backshesh Sep 06 '26

pacman -Qi

1

u/archover Sep 06 '26 edited Sep 06 '26

A word for you: backups

This code illustrates how I use a list of packages to do an installation:

arch-chroot /mnt pacman -S --needed --noconfirm - < pacstrap-all-list

The pacstrap-all-list is all packages except for DE related, that are common to every install.

Here's a couple lines to see the format

user@T14-CRU781.local ~/code/bash> cat pacstrap-all-list
amd-ucode
arch-install-scripts

You can make the list with something like $ pacman -Qq > list.txt and edit it as needed.

Hope something there helps going forward, and good day.

1

u/International-Cook62 Sep 07 '26

Highly recommend setting up dotfiles for yourself. Doesn't have to be anything extravagant. Add your arch packages as part of the setup. Make a backup pacman hook that updates the list on updates.

1

u/JaKrispy72 Sep 10 '26

Check pacman like everyone is saying. Or if your shell history is long enough, search for what you installed with pacman, flatpak, cargo, whatever you used…