The Best Ways To Recover Data On Linux

hurt harddrive   The Best Ways To Recover Data On LinuxNo matter whether it was your fault or not, things can happen to the data stored on your devices. Hard drives, solid state drives, and removable media can all potentially “lose” files because of numerous different causes. Additionally, sometimes you may delete a file – no matter if on purpose or by accident – and then determine later on that you actually need it.

Instead of freaking out over the fact that the file appears to be gone, it may be a better idea to try a file recovery tool first to recover data on Linux.

How Does File Recovery Work?

File recovery tools work on the fact that, although systems may recognize a file as “deleted”, the data may still be physically present on the storage device. For example, modern file systems determines whether space is “free” or “taken”, and can declare a space to be “free” although the data is still technically there. It simply allows the new free space to eventually be overwritten with new data.

File recovery tools can scan through the storage device to see if it can find any files that are physically still on the device, even if the file system claims that it’s gone. There are plenty of these tools available under Linux, but here are some that I recommend the most.

Safecopy

linux data recovery safecopy   The Best Ways To Recover Data On Linux

Safecopy is a rather simple data recovery tool which simply copies data to a new location. As such, it doesn’t recover individual files, but instead is a way to copy data off of a failing device.

The difference between this utility and a normal copy command is that Safecopy doesn’t quit at the first sign of file corruption, whether it be from a bad write operation or a damaged sector. There plenty of additional options to customize what the utility actually does, including the ability to create a filesystem image from damaged media, recover data as thoroughly or quickly as possible, combine data from partial sources rather than a single source, and access RAW (unpartitioned) areas of your storage media.

The utility can be installed by searching for Safecopy in your distribution’s repositories. Ubuntu users can also run the command sudo apt-get install safecopy. Once installed, you can recover files from partition X on drive “a” and write them to a pendrive with the command sudo safecopy /dev/sdaX /media/PENDRIVE_PATH/recovery_image.

TestDisk

linux data recovery testdisk   The Best Ways To Recover Data On Linux

TestDisk is a different kind of data recovery tool because it doesn’t try to copy data off a failing device, but instead can fix some partition-level issues that may be messing with your data. The utility helps recover lost partitions, make disks bootable again, fix the partition table, restore the master boot record, restore boot sectors and filesystem tables, undelete files from NTFS, FAT, exFAT, and ext2 filesystems, and copy files from deleted NTFS, FAT, exFAT, and ext2/3/4 filesystems.

The different commands for accomplishing all of these will vary widely, so it’s best to look at the utility’s documentation before getting started or look at the program interface carefully. However, it has a very nice set of features that is sure to help a lot of people get their data back onto safe hands. You can install the utility by searching your distribution’s repository for testdisk. Ubuntu users can also run the command sudo apt-get install testdisk.

PhotoRec

linux data recovery photorec   The Best Ways To Recover Data On Linux

Last but not least, if you’re focusing specifically at looking to recover videos, documents, and archives, you should check out PhotoRec. The advantage of PhotoRec, however, is that it completely ignores the file system and looks at the underlying data, which means it’ll still work if the device has been damaged or reformatted.

To prevent any issues from arising while using PhotoRec, it uses read-only access to recover the data – that way it won’t accidentally overwrite something that you may have been looking to recover. Just note that with PhotoRec, you’ll need to stop all writing operations immediately after you have the need to recover a file. Otherwise, the possibility exists that the underlying data will be overwritten with something new, making recovery impossible.

Again, there are plenty of options to look at while using this utility, including the selection of file extensions which you’re going after, so it’s best to look at the documentation for correct usage or look at the program interface carefully. In order to install, you’ll need to search for either the testdisk or photorec packages in your distribution’s repositories.

Some distributions, such as Ubuntu, combine the two programs into one package as they come from the same developer. Therefore, Ubuntu users can also install it using the command sudo apt-get install testdisk.

Conclusion

These three recovery tools should cover a broad range of data recovery needs, but undeleting files to copying over data that may be found on damaged media. Just be sure to look at the documentation for each of them carefully so that you’re doing exactly what you need to. As there aren’t many tools with graphical interfaces for system tasks, these will run solely through the terminal. Thankfully, TestDisk and PhotoRec have a terminal interface, which is still better than being driven by commands only.

Also, in case you didn’t know, all three of these tools to recover data on Linux are featured on our Best Linux Software page, along with loads of other great programs. Plus, if you’re new to Linux, then you should probably check out our guide on getting started, or even our guide specifically targeted at Ubuntu. Finally, if you need any help, just comment below or submit a question at MUO Answers!

What are your favorite data recovery utilities? Any tips on common issues or workarounds? Let us know in the comments!

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

14 Comments -

Danijel C

All these are only command line tools, or available with GUI?

Chris Marcoe

As someone who is just starting to p[lay with Linux, these are invaluable. thank you for these tools.

Nevzat A

Linux rocks as a portable recovery option!

Danijel C

It rocks in many other things too :)

Nevzat A

definitely :)

Aungmyo H

Can you post “how to make Java, MySQL, and Eclipse configuration in Ubuntu.” Because I am totally new in Ubuntu. And I hope your post will be good pointer for me.
Thanks…

Danny Stieben

I’m not very experienced in those, sorry!

Oliver

Using Linux recovery software is bit tricky as most of them need to run using commands. So novice users might face difficutlties while recovering their precious data.

Though, Stellar Phoenix Linux Recovery software is made for users from basic to advanced and will run only in GUI mode. At the end, you’ll have pretty fast and flawless recovery experience,

Thanks for your useful article though.

Joel

Hey Danny Very Impressive post about recovering data on Linux.I wanted to know if these tools work on any flavor of Linux?Thanks for sharing such a great post

Danny Stieben

They definitely should!

Mai Shun Han

WOW!!! Didn’t know that there’s such recovery tools… :D

Michel

I hate Linux & Ubuntu I installed it on my Dell >what a mistake that was< the freekin thing doesn't want to uninstall so what do I do….delete any file that as something to do with Ubuntu, Big No No now I have a dual boot but only one OS that I had to build up from scratch, theres nothing human about Ubuntu if you ask me its a bunch of crap pure and simple
Q: how in the world do I delete this ''dull'' boot even tough Ubu what you ma call it from my PC ?

David Moreira

This came in pretty handy, thanks.