HOW TO RECOVER DELETED FILES ON HARD DRIVES ON ALL OPERATING SYSTEMS

Ameen Shokoya
7 min readFeb 16, 2023

It was distressing for my client when he came to me with tears, pleading for a solution to recover his deleted files from his hard drive. I calmed him down and told him there was a way to regain his files — HIS EYES LIT UP.
As I listened to his story, I realized he wasn’t the only one who had faced this issue. In recent months, four other people have approached me with similar levels of lost files and documents, which is not a good pattern. After researching various data recovery tools, I found Photorec. This free, powerful data recovery tool can help retrieve deleted files from different storage mediums and file systems.

In this article, I’ll provide a comprehensive guide on how to use Photorec to recover lost data. By the end of this article, you’ll know how to use it to potentially save yourself or someone else from the distress and frustration of losing important information.

BRIEF DESCRIPTION OF DATA

Our hard drives are undoubtedly the most essential storage units where we store different types of files. Our hard drives hold some of our most treasured possessions — from precious photos of our loved ones to the soul-stirring music tracks of our favorite artists. These digital archives are a testament to our memories, hopes, and aspirations; losing them can be a heartbreaking experience.

In data recovery, “data” refers to any digital information stored on a storage device, such as a hard drive, USB drive, or SD card. This can include photos, videos, documents, music files, etc. Data can be lost for various reasons, such as accidental deletion, hardware failure, or formatting of a storage device. Data recovery software programs such as Photorec are designed to help recover lost data by scanning the storage device and reconstructing the file system to retrieve the lost files.

WHY PHOTOREC

Photorec is a versatile and effective data recovery tool that can retrieve deleted files from various storage devices, including hard drives, USB drives, and memory cards. One of its key features is its ability to recover lost files from multiple file systems (NTFS, Ext2/3/4, FAT32, HFS+, etc.), making it a valuable tool for Mac and Linux users with limited options regarding data recovery software.

Unlike other data recovery tools, Photorec can recover more than just photos but also videos, documents, and music files. Additionally, it’s free and open-source software that works on different operating systems, making it accessible and affordable for anyone who needs to recover lost data. This makes Photorec stand out since many other data recovery solutions aren’t free and unaffordable for most users.

With its simple and intuitive interface, Photorec is a powerful tool that can help you recover lost data in just a few easy steps.

DOES DATA RECOVERY SOFTWARE EVEN WORK? HOW DO THEY WORK?

You may be wondering how computer software can recover a deleted file. Sounds like magic, right? Well, it’s not. Here’s a simple explanation:

When a file is deleted, the data is not immediately removed from the storage device. Instead, the file system marks the space the deleted file occupies as available for new data to be written. The data can be recovered using data recovery software as long as it has not been overwritten.

Data recovery software scans the storage device for any remaining data fragments and reconstructs them into usable files. The software uses different algorithms and methods to search for and retrieve lost data, depending on the type of file system and the extent of the damage or corruption.

Therefore, it is recommended to stop using your hard drive immediately after you notice a data loss, as trying to use it after that may decrease the chances of a successful recovery.

Also, after a data loss, seek the help of a professional because the sooner you attempt to recover the lost data, the higher the chances of success since the data may get overwritten with new data if you continue to use the device.

HOW TO INSTALL PHOTOREC ON VARIOUS OPERATING SYSTEMS

Here’s a detailed instruction on how to install Photorec;

For Windows Users

  1. Go to the official website for Photorec, which is part of the TestDisk software suite. You can find it here.
  2. Scroll down to the “Download” section and click on the link for the Windows version of the software. This will download a ZIP file containing the software.
  3. Extract the contents of the ZIP file to a folder on your computer. You can do this by right-clicking on the ZIP file, selecting “Extract All,” and then following the prompts to extract the files.
If you follow the steps correctly, you should arrive at this place.

4. Open the folder containing the extracted files. You should see a file called “photorec_win.exe.” Double-click on this file to launch the software.

For Linux Users

  1. Fire up a terminal window on your Linux computer.
  2. Type the following command to install the TestDisk package, which includes Photorec:
sudo apt-get install testdisk
How to Install Photorec on Linux. I have it installed on Linux that’s why it’s like this

3. Press “Enter” to execute the command. You may be prompted to enter your password.
4. Once the installation is complete, type the following command to launch Photorec:

sudo photorec
What happens after inputting the “sudo photorec” command. As you can see, my hard drive showed up and ready for recovery.

5. Follow the on-screen instructions to recover lost data from your storage device.

For Mac Users

  1. Go to the official website for Photorec, which is part of the TestDisk software suite. You can find it here.
  2. Scroll down to the “Download” section and click on the link for the Mac version of the software. This will download a DMG file containing the software.
  3. Double-click on the DMG file to open it.
  4. Drag the “testdisk” and “photorec” icons from the DMG window to your Applications folder.
  5. Open a terminal window and type the following command to launch Photorec:
sudo photorec

6. Follow the on-screen instructions to recover lost data from your storage device.

FURTHER INSTRUCTIONS

Some users may find the CLI (Command Line Interface) of Photorec intimidating. Here are the simple steps to follow for an easy and smooth data recovery process:

  1. Launch the software and select the disk you want to recover data from. If you’re unsure which disk to choose, you can check the size and name of the disk to ensure that you’ve selected the correct one.
  2. Choose the file system that the disk uses. This can be FAT, NTFS, exFAT, or other file systems, and you can select the appropriate one from the list of options the software provides.
  3. Select the destination for the recovered files. Choosing a different disk or storage device is recommended to avoid overwriting the lost data.
  4. Start the data recovery process by following the on-screen prompts. The software will scan the disk for any remaining data fragments and attempt to reconstruct them into usable files. This process may take some time, depending on the disk’s size and the data loss’s extent.
  5. Once the scan is complete, you can preview the recovered files and choose the ones you want to recover. You can then save the recovered files to the destination you selected earlier.

WHAT NEXT

After the scan, you’ll notice that your recovered files are stored in folders named “recup_dir” with a number behind them. The data recovered may be muddled up. To solve this, I wrote two scripts (One for Windows and one for Linux & Mac). These scripts will move the recovered files in the different folders to a single folder and then sort the files by extension, i.e. (MP3 files will be saved under a folder called MP3, JPG files will be stored under a folder called JPG, etc.). The link to the scripts can be found here.

LIMITATIONS OF PHOTOREC

  1. Lack of a graphical user interface (GUI).
  2. It may not recover all file types or all parts of a file.
  3. Can’t recover files that have been overwritten.
  4. Can’t recover files from severely damaged or corrupted storage devices
  5. The Recovery process can be time-consuming and require significant system resources.
  6. It may recover duplicate or irrelevant files, which can be time-consuming.
  7. It may not preserve the original filenames or directory structure of recovered files.

TIPS TO PREVENT ACCIDENTAL FILE LOSS

  • To delete files, avoid using the “Shift + Delete” (Command + Delete on Mac) command. Instead, move them to the recycle bin or trash to be recovered if necessary.
  • Regularly back up your important files to a secure location, such as an external hard drive or cloud storage.
  • Install reliable antivirus software and keep it updated to protect your system from malware.
  • Be cautious when connecting to public networks or using external devices like USB drives. Scan them for viruses before accessing any files.
  • Avoid shutting down your computer while files are still being processed.
  • Check the health of your disk regularly using your system’s built-in disk utility, which can diagnose any issues before they lead to data loss.

OTHER DATA RECOVERY SOFTWARE

Photorec is not the only type of data recovery software available. We have Recuva, Stellar Data Recovery, EaseUS Data Recovery, GetDataBack, DiskDrill, R-Studio, etc. If you feel Photorec doesn’t work, you can try these other solutions.

CONCLUSION

Data loss can be a frustrating experience, but with the right data recovery tool, it’s possible to recover lost files. Remember to follow all tips to prevent data loss; everything will be okay.

If you enjoy this article, follow me on Twitter for more tech-related content. Leave a clap and comments below to let me know your thoughts.

I wish you a data-loss-free life.

--

--

Ameen Shokoya

App developer and IT professional. Loves computers. Skilled in technical support and currently building Android apps with Jetpack Compose.