Skip to content

How-ToSSD

How to Recover a Lost or Deleted Partition with TestDisk

A partition that has vanished or turned RAW usually still holds your files. We show how to get it back with TestDisk, the free open-source recovery tool: what to do first, how to use Analyse, Quick Search and Deeper Search, how to check your files before writing anything, and how to restore a damaged NTFS boot sector.

By , Systems & Technical Editor

6 min read

How to Recover a Lost or Deleted Partition with TestDisk

A drive that suddenly shows as "unallocated" in Disk Management, or a partition that Windows now calls RAW and offers to format, usually hasn't lost its data. Often only the partition table entry or the boot sector is damaged, and the files are still sitting on the disk. TestDisk is a free, open-source tool built for exactly this job: it searches the disk for partitions that have gone missing, lets you check that your files are really there, and writes the partition table back. This guide walks through the process using CGSecurity's official TestDisk documentation as of 29 November 2026.

Before you start: stop writing to the drive

The single most important step comes before you open any software. If a partition has vanished, don't create a new partition in the gap, don't format the drive when Windows asks, and don't copy anything onto it. TestDisk's own walkthrough shows Windows prompting "The drive is not formatted, do you want to format it now?" for a partition with a damaged boot sector, and the documentation warns you should never do so without knowing why. Microsoft gives the same advice for file recovery: don't create a partition after losing data, because it reduces the chance of a successful recovery.

A few other precautions are worth taking:

  • If it's the system drive, stop using that PC. Work from another computer with the affected drive connected as a second disk, or boot from a live USB stick. CGSecurity notes that TestDisk & PhotoRec can also be found on live CDs, and our guide to making a bootable USB with Ventoy or Rufus covers creating one.

  • Have somewhere to copy files to. A separate drive with enough free space lets you copy files off before you change anything, which is the safest order of work.

  • If the drive is failing, not just mis-partitioned, clicking, disappearing from the system or showing a bad health status, recovery software can make things worse. Check it first with our SSD health guide and consider a professional service for irreplaceable data.

  • If the drive is BitLocker-encrypted, keep your recovery key to hand; our guide to finding your BitLocker recovery key explains where it's stored.

What TestDisk can fix

CGSecurity describes TestDisk as free data recovery software licensed under the GPL (v2+), designed primarily to recover lost partitions and make non-booting disks bootable again when the cause is faulty software, certain types of virus or human error, such as accidentally deleting a partition table. Its documented abilities include:

Problem

What TestDisk can do

Deleted or missing partition

Fix the partition table and recover the deleted partition

NTFS partition shows as RAW

Rebuild the NTFS boot sector, or restore it from its backup copy

FAT32 drive won't mount

Recover the FAT32 boot sector from its backup, rebuild FAT12/16/32 boot sectors, fix FAT tables

Damaged NTFS file table

Fix the MFT using the MFT mirror

Deleted files

Undelete files from FAT, exFAT, NTFS and ext2 file systems

Partition can't be restored

Copy files from deleted FAT, exFAT, NTFS and ext2/3/4 partitions to another drive

It recognises a long list of file systems, including NTFS, FAT12/16/32, exFAT, ext2/3/4, btrfs, HFS+, APFS and XFS. TestDisk runs on Windows, Linux, macOS, the BSDs and even DOS.

Step 1: Download and run TestDisk as administrator

TestDisk comes from CGSecurity's download page as a portable application: you extract the archive, including its sub-folders, and it's ready to use, with no installer. At the time of writing the latest stable version is 7.2, released on 22 February 2024, with a 7.3 work-in-progress beta also listed; the Windows build needs Windows Vista or later. The same download includes PhotoRec, its companion file-recovery tool.

TestDisk needs administrator rights to read a physical disk. On Windows, right-click testdisk_win.exe and choose Run as administrator. It's a text-mode program: use the arrow keys and Page Up/Page Down to move, Enter to confirm, and q to go back or quit.

Step 2: Create a log and choose the disk

TestDisk first asks about a log file. Choose Create unless you have a reason not to: the log records technical details that are useful if you later need to ask for help on the CGSecurity forum.

Next, pick the physical disk with the missing partition from the list. CGSecurity says all hard drives should be detected and listed with the correct size, so check the size carefully: picking the wrong disk is the easiest way to make a bad situation worse.

TestDisk then asks for the partition table type. It auto-detects this, and the documentation says the default value is usually the correct one, so just press Enter unless you know otherwise.

Choose Analyse to see the current partition structure. TestDisk lists what's in the partition table now, and flags problems such as an invalid NTFS boot sector. Then select Quick Search.

TestDisk displays the partitions it finds as it goes. This is where you check before you commit: highlight a partition and press p to list its files. In CGSecurity's example, the missing partition turned up in the Quick Search and its folders listed correctly. Files shown in red are deleted entries. If you can browse your folders, you've found the right partition. Press q to return to the list.

Step 4: Deeper Search if something is still missing

If a partition still hasn't appeared, run Deeper Search. According to the documentation, it also looks for FAT32 backup boot sectors, NTFS backup boot sectors and ext2/ext3 backup superblocks, scanning the whole disk, so it takes much longer on a large drive.

Deeper Search can show the same partition more than once, sometimes with different sizes, and overlapping candidates may be marked D (deleted). Use p on each one: the copy with a damaged file system won't list properly, while the right one shows your files. CGSecurity stresses that partitions left marked as Deleted won't be recovered, so use the left and right arrow keys to change the correct one to P (primary) or L (logical), leaving the wrong duplicate marked D.

Step 5: Copy files off first, then Write

Before writing anything, consider copying your most important files to another drive. In the file listing, TestDisk can copy files from a partition it has found, even one you haven't restored yet. That gives you a safety net if the next step doesn't go to plan.

When every partition you want is listed with the right status, and only then, choose Write, confirm with Enter and y, and TestDisk records the partition structure. The documentation reminds you that you need to restart the computer to access your data.

Step 6: Repair a RAW NTFS partition's boot sector

If a partition is listed but Windows still sees it as RAW, its boot sector may be damaged. TestDisk's boot sector recovery screen shows the status of the NTFS boot sector and of its backup copy, and CGSecurity's menu reference explains how to reach it. In CGSecurity's example the main boot sector was bad and the backup valid, so the fix was to choose Backup BS, confirm with y, and restart. TestDisk then reported that the boot sector and its backup were both OK and identical. TestDisk can also rebuild an NTFS boot sector when no good copy exists, but treat that as a last resort and copy your files off first.

When TestDisk isn't the right tool

TestDisk works on partitions and file system structures. If a partition was reformatted, or the files themselves were deleted and the file system has since been reused, CGSecurity points to PhotoRec, its signature-based file recovery tool, instead. PhotoRec ignores the file system and searches for known file types, at the cost of losing original file names. Our roundup of the best free data recovery software covers the alternatives.

Also bear in mind:

  • SSDs are harder. Microsoft warns that when recovery fails, the free space may already have been overwritten, especially on a solid-state drive, so act quickly and keep writes to a minimum. Our guide to SSD TRIM in Windows 11 explains what the drive does with deleted data in the background.

  • Undo tools aren't backups. Once you've got your data back, set up proper backups with the Windows Backup app or a system image so you don't need TestDisk next time.

The bottom line

TestDisk is the free tool to reach for when a partition disappears or turns RAW: stop writing to the drive, run it as administrator, use Analyse and Quick Search (then Deeper Search if needed), press p to confirm your files are there, copy the important ones off, and only then Write the partition table or restore the NTFS boot sector from its backup. If the files themselves were deleted or the drive was reformatted, switch to PhotoRec, and if the drive is physically failing, stop and get professional help.

Sources

  1. 01CGSecurity, TestDisk (features, licence, supported file systems and operating systems, latest stable version)
  2. 02CGSecurity, TestDisk Step By Step (administrator rights, log, Analyse, Quick Search, Deeper Search, Write, Backup BS)
  3. 03CGSecurity, TestDisk Download (portable, version 7.2 and 7.3-WIP, Windows requirements, live CD)
  4. 04CGSecurity, PhotoRec (signature-based recovery, read-only access, file systems)
  5. 05Microsoft Support, Windows File Recovery (don't create a partition after losing data, SSD overwrite warning)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

Best Free Emulators for PC in 2026

Best Picks

Best Free Emulators for PC in 2026

The best free emulators for PC in 2026: RetroArch for retro systems in one app, PCSX2 for PS2, Dolphin for GameCube and Wii, DuckStation for PS1 and PPSSPP for PSP. We compare the systems each covers, licences, BIOS needs, hardware requirements and features from each project's official site, and explain how to stay legal with your own games and BIOS dumps.

Hannah Vance6 min

How to Set Up PCSX2 on Windows: Play Your PS2 Games on PC

How-To

How to Set Up PCSX2 on Windows: Play Your PS2 Games on PC

PCSX2 can play much of the PlayStation 2 library on a Windows PC at higher resolutions than the original console. Using PCSX2's official documentation, we explain the hardware you need, how to install it, how to dump the BIOS from your own PS2 and your game discs, which renderer to choose, how to save safely and what to check if games run slowly.

Marcus Thorne8 min

Best Local AI Video Translation and Dubbing Tools in 2026

Best Picks

Best Local AI Video Translation and Dubbing Tools in 2026

Free AI tools can now transcribe a video, translate it and dub it into another language on your own PC. We pick the best: pyVideoTrans, VideoLingo, OpenCreator (formerly KrillinAI) and SoniTranslate, comparing offline use, languages, voices, setup, licences and hardware from each project's official docs.

Hannah Vance5 min

pyVideoTrans vs VideoLingo: Which Local AI Video Translator Should You Use?

Versus

pyVideoTrans vs VideoLingo: Which Local AI Video Translator Should You Use?

pyVideoTrans and VideoLingo are popular open-source tools for translating and dubbing videos with AI on your own PC. Using each project's official docs, we compare installation, speech recognition, translation engines, dubbing voices, offline use, GPU support and licences, and say which suits which job.

Callum Reid4 min