How To Recover Deleted Files From Your Linux System
Recovering deleted/lost files on a Windows system is easy to do as there are plenty of software (both paid and free file recovery apps) that allows you to do so like a CSI expert. But what about Linux?
Recently my Linux hard disk crashed on me and it was then that I discovered that there was a limited choice of data recovery tools that I could use on my Linux system. In my desperate attempt to revive my hard disk (and the data on it), I came across these two great pieces of software TestDisk and PhotoRec that single-handedly saved my hard disk.
TestDisk – Recover Lost Partitions
TestDisk is a partition recovery software that can recover any lost partition or make a non-booting disk bootable again. It can be really handy when your hard disk has crashed due to faulty software, viruses or any accidental removal of the partition.
It doesn’t matter whether you are using Windows, Linux, Mac or any other UNIX system because TestDisk is able to recover them all.
As you can see from the image above, TestDisk is run in the terminal (or DOS) mode. That doesn’t mean it is difficult to use. There is no command line to remember. All you need to do is to move your arrow keys and press Enter to select the right answer, just like how you answer an online survey.
Select the hard disk to scan for the lost partition :
Select the partition type :
Find the lost partition :
Write the data to the partition :
Most of the time when your hard disk has crashed, or fails to boot, it doesn’t mean that it is spoilt. It could just be due to a corrupted file or accidental removal of the boot record, which can be easily fixed with TestDisk.
I have successfully restored two 80GB hard disks that originally could not be booted up.
PhotoRec – Recover Lost and Deleted Files
PhotoRec works to recover lost files from any storage devices, including video, documents, pictures and archives from hard disks, memory cards, USB thumb drives and CD-ROM’s. It doesn’t care what filesystem you are using and it goes deep under to dig out any underlying data.
Even if your storage device is severely damaged or re-formatted, there is a great chance that you can retrieve your data, as long as it has not been overwritten.
Unlike other data recovery software, PhotoRec does not come with a nice user interface and it does not allows you to select which files to restore. By default, it will recover all the files that it can find, but you can configure it to search only for a particular file extension.
A point to note while using PhotoRec: you should never restore a file to its original location as it will overwrite the data and make the file unrecoverable. Instead, restore the files to a secondary hard disk or a separate partition.
I would strongly recommend TestDisk and PhotoRec as Linux data recovery tools. Although they are not as visually appealing, their solid support for multiple platforms and filesystems give them a great advantage over other data-recovery software, not to mention that they are free too.
If you are using Windows and want to retrieve lost files, other data recovery software (such as Restoration and Undelete Plus) would be useful as they have a better interface and give you more control over which files to restore. However, if you are on Linux, Mac or any other platform other than Windows, PhotoRec would be a great alternative.