Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

PhotoRec: How to Recover Deleted Files

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

PhotoRec is a free, open-source data recovery tool that scans a storage device for file signatures and rebuilds deleted files from the raw data that remains after deletion. It works on hard drives, USB drives, memory cards, and many other media, and it can recover photos, documents, archives, and more. To use it, you need a computer with the device you want to recover from, plus a separate location to save the recovered files—never save them back onto the same drive you are recovering from.

What You'll Need

  • A computer running Windows, macOS, or Linux.
  • The storage device (hard drive, USB stick, SD card, etc.) that has the deleted files.
  • A second storage location with enough free space to hold the recovered files—this can be an external drive, a different internal drive, or a network location.
  • PhotoRec itself, which is part of the TestDisk suite. Download it from the official CGSecurity website (cgsecurity.org).
  • If the device is an SD card or USB drive, you may need a card reader or USB port.

Step-by-Step

  1. Download and extract PhotoRec. Go to the official CGSecurity site, download the version for your operating system (Windows, macOS, or Linux). The download is a compressed archive (e.g., .zip or .tar.gz). Extract it to a folder on your computer. For Windows, you'll find a file named photorec_win.exe; on macOS, photorec; on Linux, photorec (or photorec.static).
  2. Stop using the device immediately. If the deleted files are on a drive that is currently in use, unmount it or disconnect it from the computer if possible. The more you write to the drive, the lower your chance of recovery.
  3. Run PhotoRec as administrator/root. Right-click the executable and choose "Run as administrator" on Windows, or use sudo on macOS/Linux. This ensures PhotoRec has full read access to the device.
  4. Select the drive. PhotoRec opens in a terminal/command window. It shows a list of storage devices. Use the arrow keys to highlight the drive that contains the deleted files, then press Enter.
  5. Choose the partition. The next screen lists partitions on that drive. If you know which partition had the files, select it and press Enter. If you're not sure, select the whole drive (the option that says "[Whole disk]" or similar) to scan the entire device.
  6. Select the file system type. PhotoRec will ask you to choose the file system type. The default is often "Other" or "ext2/ext3"—if you see a list, pick the one that matches your partition (e.g., NTFS for Windows, HFS+ for Mac, ext4 for Linux). If you're unsure, choose "Other" or the option that says "No file system"—PhotoRec can still work by scanning raw data.
  7. Choose the file types to recover. PhotoRec asks if you want to recover only certain file types. The default is "All"—press Enter to keep it. If you want to narrow down, you can select "File Opt" to toggle specific types, but for most cases, recovering all is fine.
  8. Select the destination folder. PhotoRec will ask where to save the recovered files. Navigate to a folder on a different drive than the one you're recovering from. Use the arrow keys and press Enter to select a directory. Do not choose the same drive—this is critical.
  9. Start the recovery. After confirming your settings, PhotoRec will begin scanning. The process can take a long time depending on the size of the drive. You'll see progress bars and a count of files found. Let it run until it finishes (it will say "Recovery completed" or similar).
  10. Access the recovered files. When done, PhotoRec creates a folder named recup_dir.1, recup_dir.2, etc., in the destination you chose. Open that folder—you'll find all recovered files, but note that file names are not preserved; they are renamed based on their type (e.g., f1234567.jpg). You'll need to sort through them to find what you need.

Common Mistakes

  • Saving recovered files to the same drive. This is the #1 mistake. Writing new data to the drive you're recovering from can overwrite the deleted files, making recovery impossible.
  • Using the drive after deletion. Even normal use, like opening files or letting the OS write temporary files, can overwrite deleted data. Stop using the drive immediately.
  • Choosing the wrong partition. If you select the wrong partition, PhotoRec may scan a different area and miss your files. Double-check the drive and partition before proceeding.
  • Interrupting the scan. PhotoRec can take hours. If you stop it midway, you might not get any usable files. Be patient and let it finish.
  • Ignoring the file type list. If you accidentally deselect all file types, PhotoRec will recover nothing. Keep "All" selected unless you have a specific reason.

Tips

  • Use a USB adapter or card reader to connect the device to a different computer if possible—this avoids any background writes from your OS.
  • If the drive is failing (making clicking noises, not recognized), stop using it immediately and consider professional recovery—PhotoRec may not be able to handle hardware issues.
  • Recovered files are sorted by type, not by original location. Use the file extension to filter in your file manager.
  • For a quick test, try PhotoRec on a small USB stick with a few deleted files to get comfortable with the interface before tackling a large drive.
  • PhotoRec is command-line based, but it's menu-driven—you don't need to type commands, just use arrow keys and Enter.

Troubleshooting

PhotoRec does not detect the drive. Make sure the drive is properly connected and powered. Try a different USB port or cable. On Windows, check Disk Management to see if the drive appears. On macOS, check Disk Utility. If the drive is not recognized by the OS, PhotoRec won't see it either.

The scan finishes but no files are found. This can happen if the deleted files have already been overwritten. Try scanning the entire disk instead of just a partition, or try a different file system type. Also, ensure you didn't accidentally deselect file types.

Recovered files are corrupted or won't open. PhotoRec recovers raw data, so some files may be incomplete if the original data was fragmented or overwritten. Try opening them with a hex editor to see if they have a valid header. In some cases, you may need to use a different recovery tool, but PhotoRec is often the best free option.

The process is taking too long. Scanning a large drive can take many hours. You can reduce the time by selecting a specific partition instead of the whole disk, or by limiting file types to those you actually need. But don't rush—patience is key.

PhotoRec crashes or freezes. Try running it with a different version (e.g., the static build for Linux). Make sure you have enough RAM and free disk space on the destination drive. If the source drive has bad sectors, PhotoRec may hang—try using the --keep_bad_sectors option if you're comfortable with the command line, or consider professional help.

Frequently Asked Questions

Can PhotoRec recover files from a formatted drive?

Yes, PhotoRec can often recover files from a formatted drive because formatting typically only removes the file system index, not the actual data. However, if the drive was formatted with a full overwrite (like a secure erase), recovery is unlikely.

Does PhotoRec preserve original file names?

No, PhotoRec does not preserve file names. It renames recovered files based on their type and a sequential number (e.g., f1234567.jpg). You'll need to manually rename them after recovery.

Can PhotoRec recover files from an SSD?

It can, but SSDs use TRIM, which permanently erases deleted data blocks, making recovery less likely. If the files were deleted recently and TRIM hasn't run yet, you might get lucky, but don't count on it.

Is PhotoRec safe to use?

Yes, PhotoRec is read-only on the source drive—it only reads data and writes to the destination you choose. It won't modify the source drive, but you should still stop using the drive to avoid overwriting.

Does PhotoRec work on mobile phones?

PhotoRec runs on a computer, not directly on a phone. You can use it to recover files from an SD card or internal storage by connecting the phone as a USB mass storage device (if possible) or by removing the SD card and reading it with a card reader.

How long does PhotoRec take?

It depends on the size of the drive and the speed of your computer. A 1TB drive can take 10+ hours. Smaller drives (like a 32GB SD card) may take 30 minutes to an hour. Patience is essential.