November 24
2018
Linux Rescue and Recovery
Ubuntu Recovery Mode
GRUB > Recovery Mode
$ locate recovery-mode
/lib/ecovery-mode
System Rescue Images
Write Live Boot Images to USB Drive
- Download ISO image
- Verify downloaded image with checksum utility (MD5 or SHA256)
- Add MBR to ISO image in Ubuntu host
- # apt update
- # apt install syslinux_utils
- $ isohybrid <image>.iso
- Create Live Boot drive
- Ubuntu Startup Disk Creator
- dd
- Find target drive with these commands (if use dd):
- $ df -h (USB)
- $ lsblk (Writeable CD/DVD)
- Unmount target drive
- # umount /dev/<targetdrive>
- # umount /dev/<targetdrive>
- Write image to drive with dd
- # dd bs=4M if=<image>.iso of=/dev/<targetdrive>&& sync
- # 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