TestDisk
TestDisk is a free and open-source data recovery software utility designed primarily to recover lost partitions and make non-booting disks bootable again when affected by software faults, viruses, or human errors.[1] It achieves this by fixing corrupted partition tables, recovering deleted partitions, and rebuilding or repairing boot sectors for filesystems such as FAT32, NTFS, and ext2/ext3/ext4.[1] Additionally, TestDisk supports undeleting files from FAT, exFAT, NTFS, and ext2 filesystems, as well as copying files directly from deleted partitions.[1] The tool is compatible with a wide range of operating systems, including DOS, Windows, Linux, FreeBSD, NetBSD, OpenBSD, SunOS, and MacOS X, making it versatile for use across different environments.[1] It supports numerous filesystems, such as APFS, FAT12/16/32, exFAT, NTFS, ext2/3/4, HFS+, ReiserFS, UFS, JFS, XFS, BTRFS, enabling recovery from various storage media like hard drives and memory cards.[1] Developed by CGSecurity and released under the GNU General Public License version 2 or later, TestDisk's latest stable version as of early 2025 is 7.2, which was initially released in February 2024.[2][3] It is often used alongside its companion tool, PhotoRec, for broader file recovery needs, and is suitable for both novice users seeking expert consultation and professionals performing onsite recoveries.[1]Overview
Description
TestDisk is a free and open-source data recovery utility designed to help users recover lost partitions and repair corrupted filesystems on storage devices.[1] It addresses issues such as non-booting disks caused by software malfunctions, viruses, or accidental user errors, and supports undeleting files from various filesystems.[1] Licensed under the GNU General Public License version 2 or later (GPL v2+), TestDisk is distributed at no cost and allows modification and redistribution under its terms.[1] The software is developed and maintained by Christophe Grenier through CGSecurity, with the latest stable release being version 7.2, issued on February 22, 2024.[2][4] The tool operates via a command-line interface (CLI) featuring text-based menus, making it accessible without a native graphical user interface, though it can function within terminal environments that support GUIs.[1] This design emphasizes efficiency for both novice and expert users in diagnosing and fixing disk structures.[1] TestDisk is frequently bundled with its companion program, PhotoRec, which specializes in signature-based file carving to recover individual files independently of the filesystem; in contrast, TestDisk targets partition and filesystem-level recovery operations.[5]Development history
TestDisk was initiated in 1998 by Christophe Grenier as a DOS-based partition repair tool designed to address common disk errors such as corrupted partition tables and non-booting disks.[4][6] In the early 2000s, the tool was expanded to support cross-platform use, including ports to Linux and Windows, broadening its accessibility beyond DOS environments.[7] In April 2002, Grenier added PhotoRec as a companion tool for file carving, enabling recovery of individual files independently of the filesystem structure.[4] Key milestones in TestDisk's evolution include the release of version 6.0 in 2005, which introduced advanced support for NTFS boot sector recovery and partition undeletion.[8] Version 7.0, released on April 18, 2015, provided better support for exFAT and ext4 filesystems, along with various bug fixes and security improvements.[9] Most recently, version 7.2 in February 2024 emphasized bug fixes, performance optimizations, improved handling of exFAT filesystems including enhanced UTF-8 support, and added APFS partition detection.[2] TestDisk remains a solo project maintained by Grenier, who handles core development and packaging.[6] Contributions from the community are facilitated through the Git repository hosted at cgsecurity.org, while binary downloads are distributed via SourceForge.[10][11] The project operates without major corporate backing, relying instead on community donations and Grenier's longstanding expertise in data recovery.[12] As of November 2025, a work-in-progress version 7.3 beta is available for testing.[3]Core Features
Partition recovery
TestDisk provides robust partition recovery capabilities by analyzing and reconstructing damaged or lost partition tables on storage devices. It employs scanning algorithms to detect partition structures, including backup copies, enabling the restoration of access to data without overwriting existing content. This process is particularly effective for disks where the underlying data remains intact, allowing users to recover entire partitions that have been deleted or corrupted.[13] The tool scans disk structures by examining key areas such as the master boot record (MBR), GUID partition table (GPT), and extended partitions within the PC/Intel partitioning scheme. It locates backup partition tables or header signatures using quick and deeper search modes, which systematically probe the disk for valid partition entries based on size, type, and filesystem indicators. TestDisk supports recovery from corrupted MBRs, GPTs, and extended partitions, as well as other schemes like Apple partition maps and Sun Solaris slices. By analyzing disk geometry—such as cylinder-head-sector (CHS) or logical block addressing (LBA)—it identifies discrepancies and proposes corrections to align the partition layout with the actual data distribution.[13][14] The recovery process follows a structured sequence of steps to ensure accuracy and minimize risks. Users begin by selecting the target disk and partition table type, then initiate an analysis that performs a quick search for existing partitions. If partitions are missing, a deeper search extends the scan across the entire disk to locate lost ones, often using backup data like secondary GPT headers or extended partition chains. TestDisk lists detected partitions, allowing users to verify them by inspecting filesystem contents (e.g., via the 'p' command to list files). Once validated, the updated partition table is written back to the disk, overwriting only the corrupted table without affecting partition data. This non-destructive approach preserves the original disk state until confirmation.[14][13] TestDisk handles common failure scenarios effectively, including accidental partition deletion during repartitioning, overwrites by viruses that corrupt boot sectors, and errors from partitioning software like defragmentation tools that misalign structures. For instance, in cases of deleted FAT32 partitions following a defrag operation, TestDisk can manually add missing entries and rebuild the boot sector to restore access. Similarly, virus-induced damage to MBR or boot sectors is addressed by repairing or replacing them from backups. These recoveries succeed in scenarios where the partition data has not been overwritten, though outcomes depend on the extent of subsequent disk activity.[15][13] A key feature is the ability to make non-booting disks bootable by rewriting boot sectors for supported filesystems, such as NTFS or FAT32, using backup sectors or reconstruction tools like RebuildBS, all without data loss. This integrates with subsequent filesystem repairs if needed, but focuses primarily on partition-level restoration. Overall, TestDisk demonstrates high effectiveness for intact backup recoveries, as evidenced by its widespread use in data recovery examples.[15][13]Filesystem repair
TestDisk provides specialized tools for repairing corrupted filesystem structures within detected partitions, enabling access to data without altering the underlying partition layout. These repairs target critical components such as boot sectors and metadata tables, which are essential for mounting and reading filesystems. By focusing on logical corruptions rather than physical disk issues, TestDisk helps restore usability following events like improper shutdowns, power failures, or malware infections that disrupt filesystem integrity.[13] For FAT12, FAT16, and FAT32 filesystems, TestDisk rebuilds damaged boot sectors by analyzing the filesystem geometry to recalculate parameters such as cluster size and root directory location, or by copying from a backup boot sector if one is present and valid. This process ensures the boot sector accurately reflects the filesystem's configuration, allowing operating systems to recognize and mount the volume. Additionally, TestDisk repairs FAT tables by comparing the primary and backup copies to reconstruct a coherent version, verifying and correcting chain links between clusters, marking bad clusters as unusable, and fixing inconsistencies in directory entries to prevent cross-linked files or lost allocation. These repairs are particularly effective against corruptions caused by abrupt interruptions, as they restore the linkage that maps file data across the disk.[13] In NTFS volumes, TestDisk addresses boot sector damage by rewriting it using derived parameters or a viable backup, while also repairing the Master File Table (MFT) mirrors to synchronize the primary and secondary copies of this vital metadata structure. It further fixes issues in the $Boot file, which contains the boot sector data, ensuring consistency across NTFS's self-describing elements. For ext2, ext3, and ext4 filesystems on Unix-like systems, TestDisk locates and utilizes alternate superblocks—stored at predefined offsets like block 32768 for a 4096-byte block size—to analyze and correct superblock data, facilitating subsequent use of tools like fsck for deeper inode repairs. Although TestDisk itself does not directly modify inodes, its superblock recovery provides the foundation for restoring inode tables affected by similar corruption sources.[13] To maintain data safety, TestDisk operates in a non-destructive mode by default, allowing users to preview repairs through a "List" function that displays the filesystem structure without committing changes, and prompting for backups of original sectors before any write operations. This cautious approach minimizes risks during the repair of common corruptions from power loss or malicious software, which often leave recoverable backups intact.[13]File recovery
TestDisk provides file recovery capabilities through metadata-based methods, focusing on undeleting files from intact or partially accessible filesystems and copying data from deleted partitions without altering the original disk. This approach scans directory entries and file allocation tables to identify and extract deleted items, preserving original filenames and structures where possible, unlike signature-based carving tools.[16] For undelete operations, TestDisk supports FAT12, FAT16, FAT32, exFAT, NTFS, and ext2 filesystems by examining directory entries marked as deleted and restoring access flags without rewriting the filesystem. On FAT and exFAT, users can navigate the filesystem tree to locate deleted files and directories, which appear in red, and copy them to a separate drive. For NTFS, it scans the Master File Table (MFT) entries to list and copy individual deleted files. On ext2, recovery follows inode structures to retrieve files via directory listings. Success depends on the metadata remaining intact and the file data not being overwritten by new allocations.[17][18] TestDisk also enables copying files from deleted or inaccessible partitions across a broader range of filesystems, including FAT, exFAT, NTFS, ext2, ext3, and ext4, by virtually mounting the partition structure and browsing its contents. After analyzing the disk and identifying lost partitions, users press 'p' to list files within the partition, select items, and export them to another location, effectively salvaging data without full partition recovery. This method relies on reconstructing the filesystem layout from backups or alternate superblocks, allowing access to the original directory hierarchy.[1][14] The recovery process begins with selecting the affected disk in TestDisk, proceeding to the "Analyse" menu for quick or deeper searches to locate partitions, and then accessing the "Advanced" menu for undelete or listing files on found partitions. Users mark files or directories for recovery using keys like 'c' for copy or ':' for selection, specify a safe destination drive to avoid overwriting data, and quit to complete the operation. It is critical to recover to a different physical disk to prevent further data loss.[16][14] Limitations include the inability to recover filenames, folder structures, or fragmented files if metadata is corrupted or clusters have been reused for new data, as TestDisk does not reconstruct missing allocation chains or perform content carving. Heavily overwritten files or those on unsupported filesystems cannot be recovered this way, and results are best for recently deleted items where the original data blocks remain allocated but flagged as free. For cases beyond metadata recovery, such as fragmented or heavily damaged filesystems, TestDisk integrates with PhotoRec, its companion tool, which handles signature-based extraction but without preserving original names or structures.[17][18][19]Technical Specifications
Supported file systems
TestDisk provides support for a wide range of file systems, enabling partition recovery, filesystem repair, and in some cases file undeletion or copying. Its capabilities vary by file system, with full recovery and repair options available for common ones like FAT and NTFS, while others receive limited or read-only analysis to minimize risks. The tool detects and can recover lost partitions across all supported file systems, but repair functions are targeted at specific structures such as boot sectors and metadata tables.[1] The FAT family, including FAT12, FAT16, and FAT32, receives full support for partition recovery, boot sector repair, FAT table reconstruction, and file undeletion or copying in read-only mode. These file systems, commonly used in DOS, Windows, and removable media, benefit from TestDisk's ability to scan and restore the file allocation table (FAT) to recover deleted files and fix corruption. exFAT, an extension for larger storage devices like flash drives and external HDDs, supports undeletion, file copying, and repair of its allocation table, though it lacks some advanced boot sector fixes available for FAT.[1][1] NTFS, the default file system for modern Windows installations, offers comprehensive support including full boot sector rebuilding, Master File Table (MFT) repair, and undelete operations with file listing and copying. TestDisk can scan the MFT to recover deleted files and directories, making it particularly effective for NTFS partition issues like overwritten boot sectors or partial corruption. For the ext family—ext2, ext3, and ext4, prevalent in Linux environments—TestDisk enables superblock recovery, inode scanning for lost files, boot sector repair, and read-only undelete with file copying. These features allow reconstruction of the superblock backups and journal analysis to restore filesystem integrity.[1][1] Apple's HFS, HFS+, and HFSX file systems, used in macOS, are supported for partition recovery and basic analysis, with capabilities to detect and rebuild the catalog file for limited repair. APFS, introduced in macOS High Sierra, receives read-only analysis support, allowing partition detection and basic inspection without write operations to avoid potential data corruption risks. Other file systems include ReiserFS versions 3.5, 3.6, and 4 with support for partition recovery and limited journal repair; XFS for superblock scanning and inode recovery; ZFS with basic partition detection but no advanced repair; BeFS for partition recovery; Btrfs with limited support for superblock and metadata scanning; JFS for basic recovery; and UFS/UFS2 for inode and superblock fixes. Additional supported systems encompass CramFS (read-only), GFS2, NSS, and specialized formats like XBox FATX and Wii WBFS for partition recovery. Encrypted or container systems like LUKS, LVM/LVM2, and Linux RAID (md 0.9/1.0/1.1/1.2, supporting RAID 1/4/5/6) are detectable for partition purposes, with Swap (v1/v2) recognized as a filesystem type.[1][1] TestDisk also handles various partition table formats, including MBR (Master Boot Record) for legacy systems, GPT (GUID Partition Table) for modern UEFI-based setups, BSD disklabel for BSD Unix variants, Mac partition map for Apple volumes, and Sun/Solaris i386 disklabel for Solaris systems. These allow the tool to analyze and rebuild the overall disk structure regardless of the underlying file systems.[1]Operating system compatibility
TestDisk is a cross-platform data recovery tool designed to operate on a variety of operating systems, enabling users to perform partition and file recovery tasks without dependency on a specific host environment.[1] It originated as a DOS application but has evolved to support modern architectures through console-based execution.[4] The tool runs natively on DOS, including real-mode DOS or within a Windows 9x DOS-box, providing compatibility for legacy systems.[1] For Windows, it supports both 32-bit and 64-bit versions (Windows Vista and later, including Windows 10 and 11) via console interface, with pre-compiled binaries available for direct execution.[3] On Linux, TestDisk is compatible with all major distributions, installable through package managers such as apt on Debian/Ubuntu, dnf on Fedora, or pacman on Arch Linux, or via static Intel binaries that require no root privileges for basic use.[20] macOS users can run it through the Terminal, either by installing via Homebrew (brew install testdisk) or using official binaries, supporting versions from macOS 10.6 onward.[3] Additionally, it operates on Unix-like systems including FreeBSD, NetBSD, OpenBSD, and SunOS/Solaris, leveraging source compilation or available ports for integration.[21]
TestDisk is frequently included in live environments for bootable recovery scenarios, such as SystemRescue (formerly SystemRescueCd) and Parted Magic, allowing operation from USB or CD without installing on the host system.[22] Installation across platforms emphasizes portability: pre-compiled binaries are downloadable from the official CGSecurity website (cgsecurity.org), requiring no formal installer as the executable runs directly after extraction.[3] For custom builds, users can compile from source using Autotools (via ./configure && make) after cloning the Git repository, or CMake for broader build flexibility; this approach supports adaptation to non-standard environments.[23]
Hardware compatibility focuses on storage interfaces, with support for IDE/ATA/SATA drives, SCSI devices, USB mass storage, and SD cards, facilitating recovery from diverse media like hard disks and digital cameras.[1] Direct disk access is essential, necessitating administrator or root privileges to read raw partitions and avoid filesystem restrictions.[20] As of 2025, TestDisk maintains full compatibility with UEFI systems through its handling of EFI GPT partition tables, enabling recovery on modern boot configurations without issues. While no official ARM-specific binaries exist, the open-source nature allows compilation on ARM platforms like Raspberry Pi, with packages available in distributions such as Arch Linux ARM.[24] This cross-OS support complements its file system recovery capabilities, allowing consistent operation regardless of the host platform.[4]
Applications and Use Cases
General data recovery
TestDisk is widely used in general data recovery for addressing logical issues on storage devices, such as recovering lost partitions following an operating system reinstallation that inadvertently overwrites the partition table.[1] It also helps fix boot sector corruption caused by faulty software updates or malware, restoring access to non-booting disks without requiring advanced hardware intervention.[25] Another common application involves undeleting files accidentally removed from USB drives formatted with FAT or exFAT filesystems, where TestDisk scans for recoverable entries in the filesystem structure.[13] Best practices for using TestDisk in these scenarios emphasize preserving the original data integrity. Users should first create a disk image using TestDisk's built-in Image Creation feature in the Advanced menu or the dd command to clone the affected drive onto a separate storage device, allowing all recovery operations to occur on the copy.[26] It is critical to avoid writing any new data to the affected disk during analysis and recovery, as TestDisk operates in read-only mode by default for scanning but requires explicit user confirmation for any writes, such as partition table repairs.[13] For beginners, starting with the Analyse option to gather disk information is recommended before proceeding to deeper scans. Despite its effectiveness, TestDisk has notable limitations in general data recovery contexts. It cannot address physical damage to storage media, such as bad sectors from hardware failure, which requires specialized recovery services.[1] Similarly, it is ineffective for recovering data from encrypted volumes like those protected by BitLocker without first decrypting them using the appropriate key, as TestDisk lacks native support for encrypted filesystem parsing.[27] The tool's command-line interface provides no graphical user interface, making it unsuitable for non-technical users and necessitating familiarity with disk structures and command navigation. TestDisk performs best on logical errors, such as partition table corruption or deleted entries, often achieving high recovery rates for intact partition structures while success for individual files diminishes if filesystem metadata has been overwritten.[28] In professional workflows, it serves as an initial step to restore partition visibility before employing graphical tools like Recuva for file-level undeletion or EaseUS Data Recovery Wizard for further extraction.[29]Digital forensics
TestDisk plays a crucial role in digital forensics by enabling investigators to recover and analyze disk structures without modifying the original evidence. It supports the examination of seized storage devices, allowing for the identification of hidden or deleted partitions that may contain critical investigative data, such as in cybercrime cases involving data concealment. The tool's read-only analysis capabilities ensure that evidence integrity is maintained throughout the process, aligning with forensic standards for chain-of-custody preservation.[30][31] For evidence preservation, TestDisk employs non-destructive logging techniques, capturing disk geometry, partition tables, and filesystem metadata into hex dumps or detailed reports without writing to the source media. This is achieved through read-only modes, such as using Linux loopback devices (e.g.,losetup -r) or mounting disk images in read-only format, which prevents inadvertent modifications like timestamp alterations that could occur from mounting the drive. Investigators can thus perform triage and analysis on live or imaged evidence drives, avoiding the need for hardware write-blockers in many scenarios while countering potential challenges to evidence admissibility.[31][30]
In practical applications, TestDisk facilitates the recovery of deleted or hidden partitions on filesystems like NTFS and FAT, verifies filesystem integrity during audits, and extracts data from compromised drives, such as those affected by malware. For instance, it can undelete files and directories from NTFS volumes, including alternate data streams (ADS) often used by malware to hide payloads, without altering the original structure. Its outputs, including log files and hex views, are compatible with forensic suites like Autopsy for further analysis or EnCase for reporting, making it valuable in Digital Forensics and Incident Response (DFIR) workflows.[32][30][33]
TestDisk's advantages in forensics include its free, open-source nature and high portability, allowing deployment on bootable media for field use without installation, ideal for onsite triage. It supports advanced features like ADS searches on NTFS, enhancing detection of steganographic or hidden data. In case examples, TestDisk has recovered partitions and files in malware infection scenarios, such as the Honeynet Project's Scan 15 challenge simulating real-world compromises. It has also been tested for accuracy in NIST's Digital Forensic Tool Testing (DFTT) benchmarks, successfully handling NTFS undelete and partition recovery tasks on standardized images.[30][34]