TestDisk Step by Step - CGSecurity PDF
TestDisk Step by Step - CGSecurity PDF
TestDisk Step by Step - CGSecurity PDF
19/10/15, 9:07 AM
This recovery example guides you through TestDisk step by step to recover a missing
partition and repair a corrupted one. After reading this tutorial, you should be ready to
recover your own data. Translations of this TestDisk manual to other languages are
welcome.
Example problem
We have a 36GB hard disk containing 3 partitions. Unfortunately;
the boot sector of the primary NTFS partition has been damaged, and
a logical NTFS partition has been accidentally deleted.
This recovery example guides you through TestDisk, step by step, to recover these
'lost' partitions by:
rewriting the corrupted NTFS boot sector, and
recovering the accidentally deleted logical NTFS partition.
Recovery of a FAT32 partition (instead of an NTFS partition) can be accomplished by
following exactly the same steps. Other recovery examples are also available. For
Information about FAT12, FAT16, ext2/ext3, HFS+, ReiserFS and other partition types,
read Running the TestDisk Program.
One condition:
TestDisk must be executed with Administrator privileges.
Important points for using TestDisk:
To navigate in TestDisk, use the Arrow and PageUp/PageDown keys.
To proceed, confirm your choice(s) with the Enter key.
To return to a previous display or quit TestDisk, use the q (Quit) key.
To save modifications under TestDisk, you must confirm them with the y (Yes)
and/or Enter keys, and
To actually write partition data to the MBR, you must choose the "Write"
selection and press the Enter key.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 1 of 13
19/10/15, 9:07 AM
Symptoms
If this hard disk's primary partition contained an operating system, it would most likely
no longer boot up - due to its corrupted boot sector. If the hard disk was a secondary
(data) drive or you can connect the drive to another computer in its secondary channel
(usually where a CD/DVD drive is connected), the following symptoms would be
observed:
1. Windows Explorer or Disk Manager displays the first primary partition as raw
(unformatted) and Windows prompts: The drive is not formatted, do you want
to format it now?
Under MacOSX, if you are not root, TestDisk (ie testdisk-6.13/testdisk) will
restart itself using sudo after confirmation on your part.
Under OS/2, TestDisk doesn't handle a physical device, only a disk image.
Sorry.
To recover partition from a media image or repair a filesystem image, run
testdisk image.dd
testdisk image.E01
testdisk 'image.???'
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 2 of 13
19/10/15, 9:07 AM
FAT32 boot sector files from a TrueCrypt partition. The same method works with
filesystem encrypted with cryptsetup/dm-crypt/LUKS.
testdisk /dev/md0 to repair a filesystem on top of a Linux RAID device.
Log creation
Disk selection
All hard drives should be detected and listed with the correct size by TestDisk:
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 3 of 13
19/10/15, 9:07 AM
Use up/down arrow keys to select your hard drive with the lost partition/s.
Press Enter to Proceed.
If available, use raw device /dev/rdisk* instead of /dev/disk* for faster data transfer.
Select the partition table type - usually the default value is the correct one as
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 4 of 13
19/10/15, 9:07 AM
Use the default menu "Analyse" to check your current partition structure and
search for lost partitions.
Confirm at Analyse with Enter to proceed.
Now, your current partition structure is listed. Examine your current partition structure
for missing partitions and errors.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 5 of 13
19/10/15, 9:07 AM
The first partition is listed twice which points to a corrupted partition or an invalid
partition table entry.
Invalid NTFS boot points to a faulty NTFS boot sector, so it's a corrupted filesystem.
Only one logical partition (label Partition 2) is available in the extended partition. One
logical partition is missing.
Confirm at Quick Search to proceed.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 6 of 13
19/10/15, 9:07 AM
Highlight this partition and press p to list your files (to go back to the previous
display, press q to Quit, Files listed in red are deleted entries).
All directories and data are correctly listed.
Press Enter to proceed.
When all partitions are available and data correctly listed, you should go to the
menu Write to save the partition structure. The menu Extd Part gives you the
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 7 of 13
19/10/15, 9:07 AM
opportunity to decide if the extended partition will use all available disk space or
only the required (minimal) space.
Since a partition, the first one, is still missing, highlight the menu Deeper
Search (if not done automatically already) and press Enter to proceed.
Highlight the first partition Partition 2 and press p to list its data.
Press q for Quit to go back to the previous display.
Let this partition Partition 2 with a damaged file system marked as D(deleted).
Highlight the second partition Partition 2 below
Press p to list its files.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 8 of 13
19/10/15, 9:07 AM
It works, your files are listed, you have found the correct partition!
Use the left/right arrow to navigate into your folders and watch your files for more
verification
Note: FAT directory listing is limited to 10 clusters - some files may not appear but it
doesn't affect recovery.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 9 of 13
19/10/15, 9:07 AM
Note: The extended partition is automatically set. TestDisk recognizes this using the
different partition structure.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 10 of 13
19/10/15, 9:07 AM
If all partitions are listed and only in this case, confirm at Write with Enter, y and
OK.
To copy the backup of the boot sector over the boot sector, select Backup BS,
validate with Enter, use y to confirm and next OK.
More information about repairing your boot sector under TestDisk Menu Items. The
following message is displayed:
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 11 of 13
19/10/15, 9:07 AM
The boot sector and its backup are now both OK and identical: the NTFS boot sector
has been successfully recovered.
Press Enter to quit.
TestDisk displays You have to restart your Computer to access your data so
press Enter a last time and reboot your computer.
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 12 of 13
19/10/15, 9:07 AM
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step
Page 13 of 13