How to reinstall packages to default

There is no off-the-shelf solution - other than restoring from backup.

Usually you will have two files in the filesystem root listing the packages contained in the default installation and you can sanitize those and feed them to pacman.

  • desktopfs-pkgs.txt
  • rootfs-pkgs.txt

The steps to do so

  1. Boot the system on a live USB.
  2. Mount the system partitions
  3. Create a sanitized packagelist
  4. Feed the package list to pacman while using the root argument to point the system mountpoint.

Technically you can sneak in a step to rename folders like /mnt/var and /mnt/usr adding a .bak in the process - you can then remove them entirely if your rescue mission succeeds or copy them back in case it don’t.

I have left out - on purpose - sudo - as I want you to rethink the commands and consider their implications - instead of a copy-paste guide.

Mount your system partitions

mount /dev/sdy2 /mnt

In this case there is no need to mount the EFI partition but in case you need it

mount /dev/sdy1 /mnt/boot/efi

Creating a sanitized package list from your mounted root

cat /mnt/desktopfs-pkgs.txt | awk '{print $1;}' > ~/pkglist.txt

Feed the package list to pacman - installing to the mounted root

pacman -Syy --root /mnt - < ~/pkglist.txt
4 Likes