Introduction
When standard troubleshooting fails, these advanced rescue techniques can help you recover seemingly lost Linux systems. Always remember: with great power comes great responsibility. Proceed with caution and always back up your data before attempting these methods.
Warning: These techniques are for advanced users. Incorrect application can result in data loss or system damage. Proceed at your own risk.
1. Emergency Kernel and initramfs
When your system won't boot due to kernel or initramfs issues:
- Boot into GRUB menu
- Select the problematic entry and press 'e' to edit
- Find the line starting with 'linux' and add:
init=/bin/bash
- Press Ctrl+X or F10 to boot
- Once in bash shell, remount root filesystem as read-write:
mount -o remount,rw /
- Perform necessary repairs
- Reboot with
exec /sbin/init
2. Chroot from Live Environment
For deeper system repairs:
- Boot from a live USB
- Mount your root partition:
mount /dev/sdXY /mnt
- Mount virtual filesystems:
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
- Chroot into your system:
chroot /mnt
- Perform necessary repairs
- Exit chroot and reboot
3. Rescuing with SystemRescue
SystemRescue is a specialized Linux distribution for recovery operations.
- Boot from SystemRescue live USB
- Use tools like TestDisk for partition recovery
- Use PhotoRec for file recovery
- Access encrypted volumes with cryptsetup
4. Recovering LUKS Encrypted Volumes
If you can't access your encrypted volume:
- Boot from live USB
- Install cryptsetup if not present:
sudo apt-get install cryptsetup
- Open the encrypted volume:
cryptsetup luksOpen /dev/sdXY decrypted
- Mount the decrypted volume:
mount /dev/mapper/decrypted /mnt
- Access your data and perform repairs
5. Rescuing RAID Arrays
For software RAID issues:
- Boot from live USB
- Install mdadm:
sudo apt-get install mdadm
- Scan for RAID arrays:
mdadm --assemble --scan
- If array is degraded, you may need to force assembly:
mdadm --assemble --force /dev/md0 /dev/sdX1 /dev/sdY1
- Mount the array and perform repairs
6. Kernel Panic Analysis
To analyze kernel panics:
- Set up kdump to capture crash dumps
- Analyze dump with crash utility:
crash /usr/lib/debug/vmlinux /var/crash/vmcore
- Use commands like 'bt' for backtrace, 'ps' for process info
7. Recovering Overwritten Files
If you've accidentally overwritten an important file:
- Immediately unmount the filesystem or remount as read-only
- Use debugfs to attempt recovery:
debugfs -w /dev/sdXY
- In debugfs, use 'logdump -i <inode>' to find previous versions
Pro Tip: Always keep a bootable USB with various rescue tools (GParted, TestDisk, PhotoRec, etc.) handy for emergencies.