Introduction
Recovering data from an unbootable Linux system can be challenging but is often possible with some patience and technical know-how. As a Linux user, I have found myself in this frustrating situation a few times over the years, usually after accidentally deleting critical system files or having hardware failures. Thankfully, Linux offers several tools and methods for accessing data on unbootable systems if the hard drive is still intact. In this guide, I’ll walk through various options, from simple to advanced, to help recover your precious files and get you back up and running again.
Mounting The Drive On Another System
One of the easiest options is to simply mount the drive from the unbootable Linux PC onto another working computer. As long as the hard drive is still functioning, you can quickly access all the files by attaching it externally via USB or SATA.
To do this, I first shut down the unbootable PC and disconnect the hard drive. Then I connect the hard drive to another Linux machine, either directly via SATA or through a USB enclosure/adapter. Once connected, I use the lsblk
command to identify the attached drive.
lsblk
Next, I create a mount point and mount the drive:
mkdir /media/externaldrive
mount /dev/sdb1 /media/externaldrive
Now I can navigate to /media/externaldrive and browse my files from the unbootable system. I can copy any important data to an external drive or to the new machine’s storage. This gives me access without altering the original drive.
Using A Live CD/USB
If I can’t readily connect the unbootable drive to another device, booting with a Linux live CD/USB is an excellent option. All I need is an Ubuntu, Mint, or other Linux distribution live image and a blank CD/USB stick.
I’ll boot the unworking PC from the live media. Once loaded, I install some utilities if they aren’t included:
sudo apt update
sudo apt install lvm2 xfsprogs mdadm
Then I use lsblk
and mount
like before to access the drive and data. The process is virtually the same as mounting on another system.
Live modes are great because I can rescue data non-destructively without altering the original drive. I also don’t need another working computer. The only catch is having accessible live media prepared beforehand.
Using A File Recovery Tool
If the drive and filesystem itself are corrupted or otherwise inaccessible, file recovery tools like Testdisk can salvage data. Testdisk scans the drive and rebuilds corrupted filesystem tables to access lost files.
To use Testdisk, I install it from the repositories of a live CD:
sudo apt install testdisk
Then launch Testdisk on the unbootable drive:
sudo testdisk /dev/sdX
I follow the prompts to select my drive’s filesystem (ext4, NTFS, etc). Testdisk analyzes and rebuilds the filesystem, after which I can browse for recoverable files.
Advanced tools like Testdisk take more effort but can pull data off a badly damaged drive that can’t be mounted or accessed normally.
Chrooting Into The Installed System
For extensive data recovery, I can chroot into the full installed OS from a live environment. This gives me complete access as if I booted normally.
First I mount the root partition and other needed drives:
mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/boot
mount /dev/sda3 /mnt/home
Then I chroot into the mounted drive:
sudo chroot /mnt /bin/bash
Now I have a shell into the system as if booted regularly. I can use familiar commands and tools to locate and recover data.
Chrooting takes more steps but offers the most flexibility if other methods fail. I leverage the full power of the original installation for recovery.
Recovering Deleted Files With Extundelete
If I’ve accidentally deleted important files, utilities like extundelete can restore them if drive space hasn’t been overwritten.
After booting from live media, I install extundelete:
sudo apt install extundelete
And scan the partition where my files were deleted:
sudo extundelete /dev/sda1 --restore-all
Extundelete recovers directories and recently deleted files. As long as the deleted data hasn’t been purged or overwritten, this can resurrect lost information.
When All Else Fails, Consult A Professional
If DIY recovery efforts fail and your data is critical, consider consulting a professional data recovery service. Reputable companies have specialized tools and clean room facilities to repair drives and recover data from failed media. This comes at a cost, but can be worth it for irreplaceable family photos, important databases, and other must-save information.
Be sure to research companies thoroughly and understand costs before sending your drive. Only consider firms with strong security, confidentiality, and technical expertise recovering data from Linux systems.
Conclusion
While an unbootable Linux PC can be a scary situation, you have many options for salvaging your data. Simple mounting, live booting, recovery tools, chrooting, and undelete utilities can all retrieve lost files in various scenarios. Just stay calm, move slowly, and don’t further modify your original drive until all recovery efforts are complete. With some technical diligence, you can likely recover your valuable information and get back up and running.