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.
Step 3: Analyse, then Quick Search
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.
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.