System rescue#
System Rescue means recovering a system after it has become unbootable or unstable due to some sort of software complication (e.g. you've locked out yourself from sudo...  ) or hardware failure. Mostly you want to access the system to recover data or to fix the problem. These two goals need different approaches.
) or hardware failure. Mostly you want to access the system to recover data or to fix the problem. These two goals need different approaches.
In case of a hardware failure, you can remove the drive (provided not your hard-drive is the faulty one  ) and connect it to another computer to recover data. If you just need to resolve a software issue, you can boot from a live USB and repair the system from there.
) and connect it to another computer to recover data. If you just need to resolve a software issue, you can boot from a live USB and repair the system from there.
Now let's see how to do these.
Recover data#
- Remove hard-drive and insert to another machine  
 Boot system Boot system
- (If encrypted) Open LUKS container - cryptsetup open DEVICE LUKS_CONTAINER where: DEVICE Hard-drive device file (e.g. /dev/sdb) LUKS_CONTAINER Name of the LUKS device (e.g. CRYPT_sdb)
- Mount drive - mount DRIVE MOUNT_POINT where: DRIVE Hard-drive device file (e.g. /dev/sdb or /dev/mapper/CRYPT_sdb) MOUNT_POINT Mount point (e.g. /mnt/backup)
- Copy files - cp -av MOUNT_POINT/* DESTINATION where: MOUNT_POINT Mount point (e.g. /mnt/backup) DESTINATION Destination directory (e.g. /home/user/backup)
Data recovered! 
Access system#
This method works if the machine is still bootable without faulty hardware. Basically you boot from a live USB and chroot to the installed system.
 Boot from live USB Boot from live USB
- Mount root partition. You can mount anywhere, but I'll use - /targetin this example.- (If encrypted) Open LUKS container - cryptsetup open DEVICE LUKS_CONTAINER where: DEVICE Hard-drive device file (e.g. /dev/sdb) LUKS_CONTAINER Name of the LUKS device (e.g. CRYPT_sdb)
- Create mount point - mkdir /target
- Mount drive - mount DRIVE /target where: DRIVE Hard-drive device file (e.g. /dev/sdb or /dev/mapper/CRYPT_sdb)
 
- Mount device filesystems, so your installed system can access them - ROOT=/target for n in proc sys dev etc/resolv.conf; do mount --rbind --make-rslave /$n "$ROOT/$n"; done
- Access the installed system chroot /target
- (Optional) Mount other partitions from /etc/fstabmount -a
System accessed!
Now you can do what is needed to fix the issue, the system will behave as if you booted from the installed system.
In addition you're root! 