User:M0p/Installation/Root on btrfs recovery

From ArchWiki

Recovery

Rollback /

First, if your current screwed up system can still run commands, install grub-btrfs to include btrfs snapshots in GRUB boot options.

Then, run snapper -c root list to find out which snapshot you want to rollback to.

  # | Type   | Pre # | Date                     | User | Cleanup  | Description                             | Userdata     
----+--------+-------+--------------------------+------+----------+-----------------------------------------+--------------
 0  | single |       |                          | root |          | current                                 |              
36  | single |       | Mon Nov 16 12:00:33 2020 | root | timeline | timeline                                |              

After finding out the appropriate snapshot number to rollback to (here we use 36 as an example), run snapper --ambit classic rollback 36 to rollback.

Ambit is classic
Creating read-only snapshot of current system. (Snapshot 55.)
Creating read-write snapshot of snapshot 36. (Snapshot 56.)
Setting default subvolume to snapshot 56.

Remember the new default subvolume number 56. This will be the new / the computer will boot into. Now run grub-mkconfig -o /boot/grub/grub.cfg to let GRUB know about the new snapshots. Reboot, select snapshot 56 from GRUB menu. After reboot, run grub-mkconfig -o /boot/grub/grub.cfg again to make snapshot 56 the default boot volume. Then you won't need to manually select it again on next reboot.

Recovery in live environment

If your current system is not accessible

  1. Boot into a live Arch Linux USB/CD.
  2. Set variables in this order: target disk DISK=/dev/disk/by-id/nvme-disk, DISTRO='archlinux', ENCRYPTION_PWD='DISK ENCRYPTION PWD' and mapper_variables.
  3. Open LUKS container "echo -n $ENCRYPTION_PWD | cryptsetup open $DISK-part2 $mapper_name -"
  4. Mount all subvolumes, skip mkdir commands
  5. Mount_EFI_partition, skip mkdir commands
  6. Chroot into the old system
arch-chroot $MOUNTPOINT bash --login

Now your system is accessible again. Follow the instructions in the above section.