Description
What do you need?
In recovery situations, it's often the case that we need to be able to use chroot to access our device from a failed state. It'd be great to add a tool that could be included in the ISO that makes this process a lot more seamless to accomplish if you have the ISO available to you on a USB to aid in debug / recovery.
Below are the steps I commonly use and supply to other. The idea is we could utilize gum prompts to allow the user to select the partitions instead and then handle some of the bits in the middle so we only have to get user input where we need it.
Accessing Chroot
-
Run
lsblkand identify your drive.Locate the partition that contains /home, usually the 2nd partition on the drive (
nvme0n1p2,sda2,vda2, etc.)
- Open the LUKS2 container
cryptsetup open /dev/{your_partition_id} crypt-drive
- (You'll be prompted to enter your LUKS passphrase)
-
Confirm the device is mapped
ls -l /dev/mapper/and you should see:crypt-drive -> ../dm-0(or similar) -
Mount the unlocked device
mount -o subvol=@ /dev/mapper/crypt-drive /mnt
mount -o subvol=@home /dev/mapper/crypt-drive /mnt/home
mount -o subvol=@log /dev/mapper/crypt-drive /mnt/var/log
-
Mount the boot device (if you need it available)
mount /dev/{boot_partition} /mnt/boot -
Enter the chroot environment
arch-chroot /mnt -
Inside chroot, list files (example command)
ls -l