How to recover deleted files with TestDisk and PhotoRec

Last update: 19/05/2025
Author Isaac
  • TestDisk and PhotoRec are free, cross-platform, and open-source tools for recovering deleted partitions and files on numerous platforms. OS.
  • Recovery depends on the type of loss, the physical condition of the disk, and how quickly you respond after the deletion.
  • PhotoRec recovers files in hundreds of formats, although it doesn't retain the original filenames; TestDisk excels at restoring partitions.

Recover deleted files with TestDisk and PhotoRec

Losing important files can be a real headache, whether due to carelessness, a disk failure, accidental formatting, or even partition problems. Fortunately, there are powerful, free tools like TestDisk and PhotoRec that can help you recover your data even if it seems like everything is lost.

In this article you will discover in detail how TestDisk and PhotoRec work, how to install and use them step by step to recover deleted files or lost partitions, in what cases they are effective, and when it's best to opt for professional alternatives. Everything explained clearly, in Spanish from Spain, and with practical examples so you have everything under control.

What are TestDisk and PhotoRec?

TestDisk and PhotoRec tools for file recovery

TestDisk and PhotoRec are two free, open-source, cross-platform utilities dedicated to data recovery and partition repair. They were created by CGSecurity and have been a benchmark in the sector for more than two decades.

  • TestDisk It is mainly oriented towards the partition recovery lost or damaged, repair of sectors of Boot, partition tables, MFT, and other critical disk structures. It also includes options for recovering deleted files on certain file systems.
  • PhotoRec, although it started focused on recovering photos from memory cards, is currently one of the most effective programs for recover any type of file (images, videos, documents, music, etc.) from hard drives, mobile devices USB, SSD, SD cards, etc. Even if the file system is corrupted or the partition is lost.

Both programs work in console mode (command line). commands), which can be a bit intimidating for some users, but their menus are quite clear, and in most cases, you just need to follow the on-screen steps. They also load discs in read-only mode, preventing data overwriting and thus increasing the chances of success.

  How to use Hard Disk Sentinel to test LSI over SAS hard drives

Supported operating systems and file types

The compatibility of TestDisk and PhotoRec is one of its main strengths. They can be run on the most common operating systems:

  • DOS
  • Windows (up to Windows 10, both 32 and 64-bit)
  • Linux (x86/x64 and various architectures)
  • macOS (both PowerPC and Intel)
  • BSD, SunOS and other less common systems

Regarding the file systems supported for recovery and analysis:

  • FAT12, FAT16, FAT32
  • NTFS, exFAT
  • EXT2 / EXT3 / EXT4
  • HFS, HFS+, APFS
  • BeFS, BSD, CramFS, ReiserFS, and many others, including encrypted volumes and RAID configurations

PhotoRec is capable of recovering more than 480 different file extensions, including images, videos, documents and compressed files, among other formats common on computers and multimedia devices.

Main advantages and limitations

Using TestDisk and PhotoRec has advantages over other commercial tools:

  • Completely free and open source software: You won't have to pay for licenses or worry about restrictions.
  • Power and depth of analysis: They analyze the disk in low-level mode, detecting data even on damaged media or media without a partition table.
  • Wide compatibility of formats and systems: They work for almost any type of disk, partition or file.
  • Read-only mode: They ensure that data is not overwritten during the process, increasing the success rate.

They also have some drawbacks:

  • Text-based interface: They do not have a graphical environment, which may be less user-friendly for users unfamiliar with the terminal o DCM.
  • Limited individual file recovery on TestDisk: Although it can extract deleted files on certain systems, its greatest strength is in recovering entire partitions.
  • PhotoRec does not preserve original names or folder structure: Recovered files appear with generic names, so you need to review them afterwards.
  • No full support for modern APFS systems on macOS (although they are making progress in compatibility), and the last significant version of TestDisk dates back to 2019.

Installing TestDisk and PhotoRec on Windows and Linux

Installation is quick and easy. Here are the main steps:

On windows

  • Download the official package from CGSecurity (testdisk-7.x.win.zip). It's free.
  • Unzip into a folder. No additional installation required.
  • Inside, you will find testdisk_win.exe y photorec_win.exe.
  • Double-click on the desired one to open in console mode.
  What is the best way to use Google Maps on Android in Spanish?

On Linux

  • Use the package manager, for example in Ubuntu/Debian: sudo apt-get install testdisk
  • This command installs TestDisk and PhotoRec together.
  • You can launch them from the terminal with: sudo photorec

Quick Installation Tips

  • Always run as administrator for full disk access.
  • It is recommended to do this from a different drive than the one you want to recover., to avoid overwriting important files.

Use Cases: When to Use TestDisk and PhotoRec?

These tools cover most scenarios related to data loss on disks and removable media:

  • Recover accidentally deleted partitions (formatting, table changes, errors, viruses)
  • Repair damaged boot sectors in FAT32 or NTFS, which leave the partition inaccessible or as RAW
  • Rebuild Partition Tables and MFT in Windows
  • Recover recently deleted files if they have not been overwritten
  • Extract content from SD cards, USB drives, and hard drives, even in corrupted or unrecognized states

So, if you've lost a partition or need to recover specific files, these tools offer robust, free solutions.

Step by Step: How to Recover Files and Partitions with TestDisk

TestDisk offers a guided wizard to identify disks, analyze partitions, find lost ones, and repair or restore the original partition table.

  1. Run TestDisk as administrator. Choose to create a new log or not.
  2. Select the problematic disk or drive from the displayed list (includes external drives and USB flash drives).
  3. Choose the partition table type (MBR, GPT, etc.), usually automatically detected.
  4. Click on Analysis to analyze structure and search for lost partitions.
  5. Choose Quick Search for a quick scan. If it doesn't locate the partition, try DeeperSearch.
  6. Check the partitions found, select the corresponding one and view files with the 'p' key to check if they are accessible.
  7. When you are sure, choose Write to save the new settings.
  8. Repair the boot sector if necessary, using the appropriate option.
  9. Reboot if the program recommends it to apply changes.

TestDisk also allows you to recover deleted files on compatible systems. Simply browse, select the marked files, and copy them to a safe location.

How to Use PhotoRec to Recover Deleted Files

PhotoRec is ideal when the file system structure is damaged or the partition is no longer recognized. The basic steps are:

  1. Run PhotoRec as administrator.
  2. Choose the disk or drive from which to recover data.
  3. Select the partition or, failing that, the “no partition” option.
  4. Specify the original file system by selecting the appropriate option (“Other” for FAT, NTFS, exFAT; or the one for EXT).
  5. Decide whether to search only free space or the entire disk surface.
  6. Select a different destination folder to save the recovered files using the C key.
  7. Let PhotoRec scan the disk. The duration depends on the size and condition of the disk.
  8. Check the destination folder after the recovery. Files will appear with generic names, so you'll need to identify them manually.
  How do I make games for my Instagram Stories? Game boards and derivatives

PhotoRec works in read-only mode, ensuring that the original drive is not modified, although the original file and folder names and structure are lost.

Factors influencing the effectiveness of recovery

The possibility of successful data recovery varies depending on several factors:

  • Physical condition of the disc: Severe damage makes recovery very difficult.
  • If the files have been overwritten: Each write can erase previously deleted information. Acting early improves the odds.
  • Formatting type: A quick format offers more possibilities, while a low-level format complicates recovery.
  • File fragmentation: Archiving in fragments may affect the integrity and name of the recovered file.
  • File system and tools used: Some combinations offer better results than others.

These tools are very useful, but they don't guarantee a successful recovery. It's important not to use the affected drive until the recovery is complete and to act quickly.

attrib, icacls, and takeown commands to recover locked files
Related article:
How to Use Attrib, Icacls, and Takeown to Recover Locked Files in Windows

Leave a comment