November 24 2018

Linux Rescue and Recovery

Ubuntu Recovery Mode

GRUB > Recovery Mode

$ locate recovery-mode
/lib/ecovery-mode

System Rescue Images

  1. Knoppnix
  2. Ubuntu Boot-Repair
  3. SystemRescueCD
  4. GPARTED Live

Write Live Boot Images to USB Drive

  1. Download ISO image
  2. Verify downloaded image with checksum utility (MD5 or SHA256)
  3. Add MBR to ISO  image in Ubuntu host
    • # apt update
    • # apt install syslinux_utils
    • $ isohybrid <image>.iso
  4. Create Live Boot drive
    • Ubuntu Startup Disk Creator
    • dd
  5. Find target drive with these commands (if use dd):
    • $ df -h (USB)
    • $ lsblk (Writeable CD/DVD)
  6. Unmount target drive
    • # umount /dev/<targetdrive>
  7. Write image to drive with dd
    • # dd bs=4M if=<image>.iso of=/dev/<targetdrive>&& sync

SystemRescueCD Commands

' Network access
% net-setup
' Load light-weighed GUI
% startx
' Backup partition with DD
% dd if=/dev/sdx of=/dev/sdy
' Test hard drive
% test-driv

Mount Damaged Partition Temporarily

# mkdir /mnt/<tempdir>
# mount /dev/sdx/ /mnt/<tempdir>
' Copy useful files to healthy partition

Recovery with DDRESCUE

# apt install gddrescue
# yum install ddrescue
# ddrescue -d /dev/sdx1 \
/mnt/usb-mount/sdx1-backup.img \
/mnt/usb-mount/sdx1-backup.logfile
' Test image by writing with dd to new drive

Password Recovery with CHROOT

' Live boot first, and then determine root partition
# lsblk
# mkdir /mnt/<tempdir>
# mount /dev/<rootpart> /mnt/<tempdir>
# chroot /mnt/<tempdir>
# passwd
# exit