How to Recover Deleted Files with TestDisk
In this article
TestDisk is a free, open-source data recovery tool that can restore deleted files and repair damaged partitions. It works on Windows, macOS, and Linux, and it is especially effective for recovering files from formatted drives, corrupted partitions, or accidental deletions. Before starting, you need to download TestDisk from the official website (cgsecurity.org) and have a second storage drive or USB stick ready to save recovered files to—never recover files to the same drive you are recovering from.
What You'll Need
- A computer running Windows, macOS, or Linux.
- TestDisk downloaded from the official site (cgsecurity.org).
- A separate storage device (external drive, USB stick, or another internal drive) with enough free space to hold the recovered files.
- Administrator or root access to your system.
- Patience—recovery can take a long time depending on drive size.
Step-by-Step
- Download and extract TestDisk. Go to cgsecurity.org, download the version for your operating system, and extract the archive to a folder (e.g.,
testdisk-7.2). On Windows, you'll get a folder withtestdisk_win.exe; on Linux/macOS, you'll run it from the terminal. - Run TestDisk with administrator privileges. On Windows, right-click the .exe and select "Run as administrator." On Linux/macOS, open a terminal, navigate to the extracted folder, and run
sudo ./testdisk(orsudo testdiskif installed). - Create a log file. When prompted, choose "Create" to create a log file. This helps with troubleshooting. If you've run it before, you can select "Append" or "No Log."
- Select the disk. TestDisk will list all physical drives (not partitions). Use the arrow keys to highlight the drive that contains the deleted files, then press Enter. Be careful to select the correct drive—choosing the wrong one can cause data loss.
- Choose the partition table type. TestDisk will guess the partition table type (e.g., Intel for MBR, EFI GPT, etc.). If it's correct, press Enter to accept. If you're unsure, accept the default.
- Select the partition and choose "Undelete." In the next menu, use arrows to highlight the partition where the deleted files were, then use the right arrow key to select "Undelete" at the bottom and press Enter. (Alternatively, you can use "Advanced" > "Undelete" for more options.)
- Navigate to the folder that contained the deleted files. TestDisk will show a file browser. Use arrow keys to move into directories. Deleted files are shown with a red color and often have a
?in the first character of the filename. - Select files to recover. Press
C(capital C) to copy a file, orato select all files in the current directory. You can also useShift+Cto copy all files in a directory. After pressing C, choose a destination directory (on your separate drive) and press Enter to confirm. - Repeat for other files. Continue navigating and copying files until you've recovered everything you need. When done, press
qto quit the file browser, thenqagain to exit TestDisk. - Check the recovered files. Open the destination folder and verify that the files open correctly. Some files may be corrupted if the disk was heavily overwritten.
Common Mistakes
- Recovering to the same drive. Writing recovered files back to the same drive can overwrite the very data you're trying to save. Always use a different physical drive.
- Selecting the wrong disk. TestDisk lists entire physical drives, not partitions. Choosing the wrong drive can lead to recovery from the wrong location or even damage.
- Using TestDisk on a failing drive. If your drive is making clicking noises or is not recognized, stop immediately. TestDisk is not designed for hardware failures; continuing can cause further damage.
- Skipping the log file. The log file helps diagnose problems if recovery fails. It's worth creating it.
- Not using the right partition table type. If you select the wrong type, TestDisk may not see the partition correctly. If you're unsure, try the default, but if it fails, rerun and choose a different type.
Tips
- Stop using the drive immediately. The sooner you stop writing new data to the drive, the higher the chance of recovery.
- Use a USB adapter or external enclosure. If you're recovering from an internal drive, connect it via USB to another computer to avoid booting from it.
- Recover in batches. Copy files in groups rather than one by one; it's faster and reduces the chance of missing files.
- Look for the
?character. Deleted files often have a?in the first letter of their name (e.g.,?report.docx). You can rename them after recovery. - Back up your data regularly. TestDisk is a safety net, but it's not a substitute for a good backup strategy.
Troubleshooting
TestDisk doesn't see the drive. Make sure the drive is properly connected and recognized by your operating system. On Windows, check Disk Management; on Linux, use lsblk. If the drive is not detected, it may be a hardware issue—try a different cable or port.
No deleted files are shown. This can happen if the files were overwritten or if the partition is severely damaged. Try using the "Advanced" > "Undelete" option instead, or run a deeper scan with "Analyze" first to repair the partition table.
Recovered files are corrupted. Some corruption is normal if the files were partially overwritten. Try recovering an older version from a backup, or use a file-carving tool like PhotoRec (which comes with TestDisk) for certain file types.
TestDisk crashes or freezes. Close other programs, run it as administrator/root, and ensure your system meets the minimum requirements. If it continues, try the 32-bit version or a different computer.
You can't write to the destination drive. Ensure the destination drive has enough free space and is formatted with a filesystem your OS can write to (e.g., NTFS, FAT32, exFAT). If it's read-only, check its permissions.
Frequently Asked Questions
Is TestDisk safe to use?
Yes, when used correctly. It only reads data from the source drive unless you explicitly write changes (e.g., when repairing a partition table). For file recovery, it only reads, so it won't harm your data if you follow the steps.
Can TestDisk recover files from a formatted drive?
Yes, TestDisk can often recover files from a formatted drive, especially if the format was quick (not a full overwrite). The "Undelete" function works on many filesystems, including NTFS, FAT, ext2/3/4, and HFS+.
How long does recovery take?
It depends on the drive size and the number of files. A small USB stick might take minutes, while a large hard drive could take hours. Be patient and don't interrupt the process.
Can I recover files from a drive that won't boot?
Yes, if the drive is still physically readable. Connect it to another computer and run TestDisk from that system. If the drive has bad sectors, you may need to clone it first with a tool like ddrescue.
Does TestDisk work on SSDs?
Yes, but recovery is less likely to succeed on SSDs because of the TRIM command, which permanently erases deleted blocks. If TRIM is enabled, deleted files may be unrecoverable.
What file systems does TestDisk support?
TestDisk supports NTFS, FAT12/16/32, exFAT, ext2/3/4, HFS+, and ReiserFS, among others. It also supports partition table repair for MBR, GPT, and others.