How to Use TestDisk to Recover Lost Partitions (Step by Step)
TestDisk is a free, open-source tool from CGSecurity built for one job that most recovery apps don’t handle well: finding lost partitions and repairing damaged boot sectors. If a drive suddenly shows as unallocated, a partition vanished after a resize or reinstall, or a volume won’t mount, TestDisk can often find the original partition and either restore it or let you copy the files off. It’s powerful, text-based, and capable of making things worse if used carelessly, so this guide covers both the steps and the warnings.
What is TestDisk?
TestDisk scans a drive for the structures that define partitions and file systems, such as partition table entries, boot sectors, and their backups. When it finds a partition that’s no longer listed in the partition table, it can:
- Show you the files inside it so you can confirm it’s the right one
- Copy those files to another drive without changing anything on the source
- Write a corrected partition table so the partition reappears in Windows, macOS, or Linux
- Repair or restore boot sectors for supported file systems such as FAT and NTFS
It runs on Windows, macOS, and Linux, and ships in the same download as its companion tool, PhotoRec, which recovers individual files by signature when the file system can’t be saved.
TestDisk is the right tool for lost partitions. If your partition is still there but the drive shows as RAW, see RAW drive: CHKDSK is not available. For a broader explanation of what an unallocated drive means, see our guide to partition recovery on an unallocated drive.
Before you start
- Confirm the drive is physically healthy. A drive that’s clicking, freezing, disconnecting, or reporting the wrong capacity has a hardware problem, and TestDisk can’t fix it. See how to check hard drive health.
- Don’t initialize, format, or create a new volume on the drive in Disk Management or Disk Utility. That overwrites the structures TestDisk needs.
- Have a separate drive ready for any files you copy out.
- If the data is irreplaceable, image the drive first and run TestDisk on the image. Then a mistake costs you nothing.
How to download and run TestDisk
Download TestDisk from the official CGSecurity site (cgsecurity.org). On Windows, extract the archive to a drive other than the one you’re recovering and run testdisk_win.exe as administrator. On Linux and macOS, install it from your package manager or the official download and run it with admin rights:
# Debian / Ubuntu
sudo apt install testdisk
# macOS with Homebrew
brew install testdisk
# Run with admin rights so TestDisk can read the disk
sudo testdisk
TestDisk is keyboard-driven. Use the arrow keys to move, Enter to select, and the letters shown on screen for specific actions.
How to use TestDisk, step by step
1. Create a log
The first screen asks about logging. Choose Create. The log (testdisk.log) records what TestDisk found and is useful if you need help later.
2. Select the disk
TestDisk lists every drive it can see. Pick the affected drive by its size and model, double-checking that you haven’t selected your system drive by mistake, and choose Proceed.
3. Select the partition table type
TestDisk suggests the type it detects. For most drives:
- Intel for MBR-partitioned disks (older or smaller drives, many external drives)
- EFI GPT for GPT-partitioned disks (most modern internal drives and large disks)
Accept the suggestion unless you know it’s wrong. Choosing the wrong type leads to confusing results.
4. Analyse
Choose Analyse. TestDisk shows the partition structure it currently sees, which may be empty or incomplete. That’s expected when partitions are missing.
5. Quick Search
Choose Quick Search. TestDisk scans for partitions and lists what it finds, with the file system type, start and end positions, and size.
6. List files to verify (press P)
Highlight a found partition and press P to list its files. This is the most important check in the whole process:
- If you see your folders and files with correct names, you’ve likely found the right partition.
- If you see an error, garbage names, or nothing at all, it may be a stale or damaged entry.
Press Q to go back to the partition list.
7. Deeper Search, if needed
If Quick Search didn’t find the partition you need, choose Deeper Search. It scans more of the disk and takes longer. It may also find old partitions that existed before, so verify each candidate with P again.
8. Set partition status
In the results list, each partition is marked with a status you can change with the left and right arrow keys: P (primary), * (primary, bootable), L (logical), E (extended), or D (deleted, meaning it won’t be written). Mark the partitions you want to restore and set everything you don’t want to D.
9. Write, only when you’re confident
Press Enter to move to the final screen, choose Write, and confirm with Y. TestDisk writes the new partition table to the disk. You’ll usually need to restart the computer or reconnect the drive for the partition to appear.
A strong warning about Write
Writing changes the drive’s partition table. If you write the wrong partitions, overlapping partitions, or an old partition from a previous setup, the current data can become harder to recover, not easier.
Only choose Write when all of these are true:
- You’ve listed the files with P and they’re the files you expect.
- The partition sizes make sense for the drive.
- There are no overlapping partitions in the list.
- You have an image of the drive, or the data is not irreplaceable.
If you’re unsure about any of these, don’t write. Copy the files out instead.
How to copy files out without writing anything
TestDisk can copy files from a found partition to another drive while leaving the source completely untouched. This is the safer option in most cases.
- Follow steps 1 to 6 above until you can see your files with P.
- Navigate the folders with the arrow keys and Enter.
- Mark what you want to copy:
:(colon) selects the highlighted file or folderaselects all files in the current folder
- Press
Cto copy the selected files, orcto copy only the highlighted file. - Choose a destination folder on a different drive and confirm.
Once your files are safely copied and verified, you can decide whether to write the partition table at all.
Repairing boot sectors
If a partition is listed but won’t mount because its boot sector is damaged, TestDisk’s Advanced menu offers boot sector tools for supported file systems, such as comparing the main boot sector with its backup and restoring or rebuilding it. These options also write to the disk, so the same rule applies: copy your files out first, and image the drive if the data matters.
When TestDisk isn’t the right tool
- The drive is clicking, not detected, or dropping offline. That’s a hardware failure, and scanning makes it worse.
- The drive was reformatted and new data was written. The old partition structures may be overwritten. File carving may still help.
- TestDisk finds the partition but files are missing or damaged. The file system itself may be corrupted. Try PhotoRec on the partition, or get professional help.
The bottom line
TestDisk is an excellent free tool for lost partitions and damaged boot sectors. Create a log, choose the right partition table type, run Quick Search then Deeper Search if needed, and always verify with P before doing anything else. Copying files to another drive is the safe option. Writing a new partition table works well when you’re confident, but it changes the disk, so image first if you have any doubt.
If TestDisk can’t find your partition or the drive is physically failing, our hard drive recovery service can help. It’s one flat $1,200 rate for a single device, with free prepaid shipping, and you pay only if the recovery succeeds.
