TestDisk Step by Step - CGSecurity
TestDisk Step by Step - CGSecurity
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.
Contents
1 Example problem 2 Symptoms 3 Running TestDisk executable 4 Log creation 5 Disk selection 6 Partition table type selection 7 Current partition table status 8 Quick Search for partitions 9 Save the partition table or search for more partitions? 10 A partition is still missing: Deeper Search 11 Partition table recovery 12 NTFS Boot sector recovery 13 Recover deleted files
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.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step
1/13
6/28/13
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 A r r o wand P a g e U p / P a g e D o w nkeys. To proceed, confirm your choice(s) with the E n t e rkey. 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 E n t e rkeys, and To actually write partition data to the MBR, you must choose the "Write" selection and press the E n t e rkey.
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: T h ed r i v ei sn o tf o r m a t t e d ,d oy o uw a n tt of o r m a ti tn o w ? [You should never do so without knowing why!] 2. A logical partition is missing. In Windows Explorer, that logical drive is no longer available. The Windows Disk Management Console now displays only "unallocated space" where this logical partition had been located.
6/28/13
Under Unix/Linux/BSD, you need to be root to run TestDisk (ie. s u d ot e s t d i s k 6 . 1 3 / t e s t d i s k _ s t a t i c ) Under MacOSX, if you are not root, TestDisk (ie t e s t d i s k 6 . 1 3 / t e s t d i s k ) 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
t e s t d i s ki m a g e . d dto
work from a raw disk image t e s t d i s ki m a g e . E 0 1to recover files from an Encase EWF image t e s t d i s k' i m a g e . ? ? ? 'if the Encase image is split into several files. To repair a filesystem not listed by TestDisk, run t e s t d i s kd e v i c e , i.e.
t e s t d i s k/ d e v / m a p p e r / t r u e c r y p t 0or t e s t d i s k/ d e v / l o o p 0to
repair the NTFS or FAT32 boot sector files from a TrueCrypt partition. The same method works with filesystem encrypted with cryptsetup/dm-crypt/LUKS. t e s t d i s k/ d e v / m d 0to repair a filesystem on top of a Linux RAID device.
Log creation
Choose Create to instruct Testdisk to create a log file containing technical information and messages, unless you have a reason to append data to the log or you execute TestDisk from read only media and must create the log elsewhere. Choose None if you do not want messages and details of the process to be written into a log file (useful if for example Testdisk was started from a read-only location). Press Enter to proceed.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step 3/13
6/28/13
Disk selection
All hard drives should be detected and listed with the correct size by TestDisk:
Use up/down arrow keys to select your hard drive with the lost partition/s. Press Enter to Proceed. If available, use raw device / d e v / r d i s k *instead of / d e v / d i s k *for faster data transfer.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step
4/13
6/28/13
Select the partition table type - usually the default value is the correct one as TestDisk auto-detects the partition table type. Press Enter to Proceed.
Use the default menu "Analyse" to check your current partition structure and search for lost partitions.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step 5/13
6/28/13
Confirm at Analyse with Enter to proceed. Now, your current partition structure is listed. Examine your current partition structure for missing partitions and errors.
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.
6/28/13
Confirm according to your OS and created partitions to proceed. TestDisk displays the first results in real time. (click on thumb to display the image).
During the Quick Search, TestDisk has found two partitions including the missing logical partition labeled P a r t i t i o n3 .
Highlight this partition and press p to list your files (to go back to the previous display, press q to Quit).
www.cgsecurity.org/wiki/TestDisk_Step_By_Step 7/13
6/28/13
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 E x t dP a r tgives you the 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.
6/28/13
Deeper Search will also search for FAT32 backup boot sector, NTFS backup boot superblock, ext2/ext3 backup superblock to detect more partitions, it will scan each cylinder (click on thumb).
After the Deeper Search, the results are displayed as follows: The first partition "Partition 1" was found by using backup boot sector. In the last line of your display, you can read the message "NTFS found using backup sector!" and the size of your partition. The "partition 2" is displayed twice with different size. Both partitions are listed with status D for deleted, because they overlap each other.
Highlight the first partition P a r t i t i o n 2and press p to list its data. The file system of the upper logical partition (label Partition 2) is damaged (click on thumb).
Press q for Quit to go back to the previous display. Let this partition P a r t i t i o n 2with a damaged file system marked as D ( d e l e t e d ) . Highlight the second partition P a r t i t i o n 2below Press p to list its files.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step 9/13
6/28/13
It works, 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. Press q for Quit to go back to the previous display. The available status are Primary, * bootable, Logical and Deleted. Using the left/right arrow keys, change the status of the selected partition to L ( o g i c a l )
www.cgsecurity.org/wiki/TestDisk_Step_By_Step
10/13
6/28/13
Hint: read How to recognize primary and logical partitions? Note: If a partition is listed *(bootable) but if you don't boot from this partition, you can change it to Primary partition. Press Enter to proceed.
If all partitions are listed and only in this case, confirm at Write with Enter, y and OK. Now, the partitions are registered in the partition table.
6/28/13
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:
The boot sector and its backup are now both OK and identical: the NTFS boot sector has been successfully recovered. Press Enter to quit.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step 12/13
6/28/13
TestDisk displays You have to restart your Computer to access your data so press E n t e ra last time and reboot your computer.
www.cgsecurity.org/wiki/TestDisk_Step_By_Step
13/13