Select font size:          

 

How to recover partitions using testdisk

Testdisk is very well known under Linux. However, it also exists for Windows and Mac.
TestDisk is a free data recovery software designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error. It can also be used to repair some filesystem errors.


Start the application with the command "testdisk":

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org

  TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.

Select a media (use Arrow keys, then press Enter):
 Disk /dev/sda - 250 GB / 232 GiB - Samsung SSD 850 EVO 250GB
>Disk /dev/sdb - 500 GB / 465 GiB - Hitachi HTS547550A9E
>[Proceed ]  [  Quit  ]

Note: Disk capacity must be correctly detected for a successful recovery.
If a disk listed above has an incorrect size, check HD jumper settings and BIOS
detection, and install the latest OS patches and disk drivers.

Select the media on which you want to search for deleted partitions, here /dev/sdb. Press "Enter" to proceed.

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org


Disk /dev/sdb - 500 GB / 465 GiB - Hitachi HTS547550A9E

Please select the partition table type, press Enter when done.
>[Intel  ] Intel/PC partition
 [EFI GPT] EFI GPT partition map (Mac i386, some x86_64...)
 [Humax  ] Humax partition table
 [Mac    ] Apple partition map (legacy)
 [None   ] Non partitioned media
 [Sun    ] Sun Solaris partition
 [XBox   ] XBox partition
 [Return ] Return to disk selection

Note: Do NOT select 'None' for media with only a single partition. It's very rare for a disk to be 'Non-partitioned'.

Select “Intel” and press "Enter" to proceed.

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org


Disk /dev/sdb - 500 GB / 465 GiB - Hitachi HTS547550A9E
     CHS 60801 255 63 - sector size=512

>[ Analyse  ] Analyse current partition structure and search for lost partitions
 [ Advanced ] Filesystem Utils
 [ Geometry ] Change disk geometry
 [ Options  ] Modify options
 [ MBR Code ] Write TestDisk MBR code to first sector
 [ Delete   ] Delete all data in the partition table
 [ Quit     ] Return to disk selection


Note: Correct disk geometry is required for a successful recovery. 'Analyse'
process may give some warnings if it thinks the logical geometry is mismatched.

Select "Analyse" to search for lost partitions and press "Enter":

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org

Disk /dev/sdb - 500 GB / 465 GiB - CHS 60801 255 63
Current partition structure:
     Partition                  Start        End    Size in sectors

No partition is bootable



*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
>[Quick Search]
                            Try to locate partition

Select "Quick search" to try to locate a partition and press "Enter" to proceed.

Wait until the full hard disk has been analysed. This will take a while, depending on the size of the hard disk. It will tell you something like the following:

Disk /dev/sdb – 500 GB / 465 GiB – CHS 60801  255  63

Analyse cylinder 40540/60800: 66 %

HPFS – NTF   0    32    33    38244    193    29    614400000   [exthd1]

Once finished, the outcome should look as follows:


TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org

Disk /dev/sdb - 500 GB / 465 GiB - CHS 60801 255 63
     Partition               Start        End    Size in sectors
>* HPFS - NTFS              0  32 33 38244 193 29  614400000 [verb1-1]



Structure: Ok.  Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
*=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
Keys A: add partition, L: load backup, T: change type, P: list files,
     Enter: to continue
NTFS, blocksize=4096, 314 GB / 292 GiB

Press "Enter" to proceeed.


TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org

Disk /dev/sdb - 500 GB / 465 GiB - CHS 60801 255 63

     Partition                  Start        End    Size in sectors

 1 * HPFS - NTFS              0  32 33 38244 193 29  614400000 [verb1-1]


 [  Quit  ]  [ Return ]  [Deeper Search] >[ Write  ]
                       Write partition structure to disk

In order to write the partition back to the hard disk, select "Write" and press "Enter".


TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER 
https://www.cgsecurity.org

Write partition table, confirm ? (Y/N)

To confirm, enter "Y".

In some cases you may have to reboot in order to see the changes.


Check for similar articles.