Quick Answer

TestDisk repairs lost disk partitions and boot tables; PhotoRec extracts deleted files based on their file signatures (file carving). Both are free, open source and made by CGSecurity. The golden rule for safe use: image the disk first, never write to the original drive, and save recovered data to a different disk. On a physically failed drive these tools will not help.

What Are TestDisk and PhotoRec?

TestDisk and PhotoRec are two free data recovery tools developed by French developer Christophe Grenier and CGSecurity under the GPL license. They ship in the same package and run on Windows, macOS and Linux. Portable versions need no installation, so you can run them directly from a USB stick.

Both are command line, text menu tools. They have no polished interface, but they are proven utilities used worldwide by amateurs and professionals alike for decades. Their key advantage is being completely free and transparent: they are not black boxes, the source code is open to everyone.

If you want the general logic of data recovery first, we suggest reading that article; here we focus specifically on these two open source tools.

What Does TestDisk Do?

TestDisk steps in when the logical disk structure is damaged. Its core expertise is partition recovery. That is, the disk is physically healthy, but the operating system does not recognize it or a partition has suddenly disappeared.

Typical TestDisk use cases include:

  • Finding and rewriting lost or deleted disk partitions
  • Rebuilding a damaged partition table
  • Repairing the boot sector on FAT, NTFS, exFAT, ext2/3/4 file systems
  • Restoring an accidentally deleted NTFS or FAT boot sector from backup
  • Making a partition bootable again

When TestDisk succeeds, your files come back as they were, with their folder structure and file names intact. That is because TestDisk does not recover files one by one; it repairs the disk map. This is why it is the first tool to try for partition problems.

What Does PhotoRec Do?

Despite the word "photo" in its name, PhotoRec can recover more than 480 file types, not just photos. Its logic is entirely different: it looks at file signatures, not the file system. This is called file carving.

PhotoRec scans the disk sector by sector and looks for known file start signatures. For example, a JPEG file has specific bytes at its start; when PhotoRec sees them, it starts extracting the file from that point. The big advantage of this approach is that it can recover data even when the file system is completely gone.

But it comes at a cost: PhotoRec cannot recover file names or folder structure. The output arrives as thousands of files numbered with automatic names like f0000123.jpg. You have to sort and rename them manually afterward. Fragmented files may also be recovered incompletely.

In short, PhotoRec is the last resort used when TestDisk cannot recover the partition, or after a format or deep deletion.

TestDisk vs PhotoRec Comparison

Feature TestDisk PhotoRec
Main purpose Partition and boot table repair Signature based recovery (carving)
Working logic Repairs disk structure Scans file signatures
File names preserved Yes No (auto numbered)
Folder structure preserved Yes No
Supported file types Depends on file system 480+ types
When to choose Partition loss, disk not recognized Format, deep deletion, broken file system
License GPL (free) GPL (free)
Platform Windows, macOS, Linux Windows, macOS, Linux

A rough rule: TestDisk first, PhotoRec if that fails. If your partition comes back, everything falls into place with its names. If not, with PhotoRec you at least extract the raw files.

Step by Step Safe Use

How you use these tools matters as much as the tools themselves. A recovery done in the wrong order can permanently destroy recoverable data. Do not break the sequence below.

1. Stop using the disk immediately

The moment you notice data loss, stop everything that writes to that disk. If possible, shut down the computer. Deleted data actually still sits on the disk; it is recoverable until new data is written over it. Every new file, every update, even the operating system background processes risk overwriting that data.

2. Take a sector by sector disk image first

This is the step professionals never skip. Without touching the original disk, take a sector by sector exact copy (an image). On Linux ddrescue, on Windows suitable imaging tools do this job. From then on, run all recovery attempts on the image file. That way if you make a mistake the original disk stays unharmed and you can start over.

3. Write recovered data to a DIFFERENT disk

There is no exception to this rule. When running recovery software, never write the output to the source disk itself. Use a separate disk, external HDD or a USB stick with enough free space for the output. When PhotoRec asks for an output folder, point it to a different physical disk.

4. Try the partition with TestDisk

First run TestDisk and select the disk (or the image file), choose the partition table type, and use "Analyse" to search for lost partitions. You can verify the found partition, list the files, and copy them to another disk before even rewriting the partition.

5. Switch to PhotoRec if needed

If TestDisk cannot bring the partition back, run PhotoRec, select the source, narrow the file types if needed, and point the output folder to another disk. When the scan finishes, review the numbered files and pick out the ones you need.

The Biggest Risks

Do not skip this section. The mistakes below turn recoverable data into unrecoverable data.

Writing the recovery software or its output to the same disk permanently destroys the data. This is by far the most common fatal mistake. You end up writing new data exactly over the deleted files you are trying to recover. For details, read our article on the danger of writing recovery software to the same disk.

On a physically failed disk these tools will not work and will wear the disk out more. If the disk makes a clicking noise, is not recognized at all, slows down and freezes, or has many bad sectors, this is a mechanical or electronic failure. Software cannot solve it. Worse, forcing a failed disk to read again and again (TestDisk/PhotoRec run long scans) wears the read head or platter further and makes things worse. The moment you hear clicking, power down the disk and do not touch it.

On SSDs, deleted data is often permanently gone due to TRIM. Modern SSDs physically wipe deleted blocks in the background with the TRIM command. So a file you delete on an SSD truly disappears shortly after you empty the recycle bin. This is a hardware reality; no software can bring it back. TestDisk and PhotoRec are also helpless in this case.

When Are These Tools Enough, When Is a Lab Mandatory?

Let us be honest: TestDisk and PhotoRec are powerful tools, but they do not solve every problem. Knowing their limits protects both your data and your time.

These tools are usually enough when: the disk is physically healthy; a partition was accidentally deleted or formatted; files were deleted but not much was written over the disk; there is no mechanical noise or recognition problem. In these scenarios, with some patience and care, you can recover the data yourself.

A professional lab is mandatory when: the disk makes clicking or grinding noises; it is not recognized at all or does not appear in BIOS; it was exposed to water, fire or impact; the SSD controller is faulty; a RAID array collapsed; the data is critical and you have only one attempt. These cases require a clean room, donor parts and special equipment; tinkering with software makes things worse.

Remember: the most critical rule of recovery is to get the first attempt right. A wrong software attempt can destroy data that even a lab could otherwise have recovered. If the data is truly valuable to you and you have the slightest doubt, consult an expert before taking the risk.

If you are curious about other free and paid options, see our best data recovery programs comparison, and for deleted files only our recovering deleted files guide.

About DSET

DSET has served in data recovery and digital forensics since 2003 at Ankara Hacettepe Teknokent, Beytepe, Cankaya. Our success rate in hard disk, SSD, RAID and memory card recovery is 99.4%. The first diagnosis is free and there is no charge if no data is recovered. For cases you cannot solve with TestDisk or PhotoRec, especially when physical failure is suspected, you can reach us at +90 536 662 38 09. Call before tinkering with the disk; most of the time that is the right first step.

Frequently Asked Questions (FAQ)

Are TestDisk and PhotoRec really free? Yes. Both are GPL licensed, completely free and open source software. There are no hidden fees, no per file charges and no license limits. You can download them from CGSecurity's official site.

If TestDisk can preserve file names, why do I need PhotoRec? TestDisk recovers with names only if the file system structure is intact enough. If the disk was formatted, the file system is completely broken or a deep deletion was done, TestDisk fails. In that case PhotoRec, while it cannot recover names, can extract the raw data from file signatures.

Can I recover a deleted file from my SSD with these tools? Most of the time, no. Modern SSDs physically wipe deleted blocks shortly after with the TRIM command, so the data is permanently gone. No software can bring it back. On HDDs the chances are higher.

My disk makes a clicking noise, can I still try TestDisk? No. Clicking is a sign of mechanical failure and software cannot solve it. Worse, forcing the disk to read again worsens the failure and can also destroy recoverable data. Power down the disk immediately and go to a professional lab.

Why should I take a disk image before starting recovery? Because working on the original disk is risky; if you make a mistake or the disk fails during the process, you lose the data. After taking an exact image you do all attempts on the image, the original disk stays safe, and you can retry as many times as you want.

Sources