TestDisk is a powerful data recovery software that is primarily used for recovering lost partitions. The software comes bundled with another utility called Photorec which is geared towards the more common task of recovering deleted / lost files.
Photorec is similar to other free popular file data recovery programs like Recuva though unlike them works on the command line. A GUI version qphotorec is however provided with TestDisk though it provides less customization options compared to Photorec.
Unfortunately, Photorec only provides a detailed scan which can last several hours on large disks / partitions. This is unlike other data recovery programs which offer a quick scan mode which is always worth a try before using the detailed (deep) scan modes. The upside of this detailed scan, however, is that Photorec tends to fare better at recovering lost files (albeit at times with a lot of duplicates or existing files).
When you run Photorec, one gets the option to recover data from either the whole disk or specific partitions. In both cases, one can either scan the unallocated space (free space) or the whole partition / disk for files to recover. To save time, you may consider starting either of these scans at specific sectors on the disk / partition. Here’s how to go about it:
1. Run Photorec and select the disk or partition to recover the files from.
2. Select whether to analyse the free space or the entire disk / partition.
3. Select the folder where to save the recovered files. Ensure you select a different partition or disk from the one you’re trying to recover data from. The scan will begin immediately after selecting the target folder.
4. Select the Stop option to interrupt the scanning, then exit the program.
5. Go to the TestDisk installation folder, and find a new file called photorec.ses. Open this file using a plain text editor like notepad, vim etc.
6. Edit the last number in the long line containing the recovery parameters with the specific sector you want to begin at. The following is an example of the file with the number to edit highlighted:
7. Save the file and run Photorec.
8. Press Y when prompted whether to resume the previous session.
9. Select the folder to save the recovered files then press C to begin the scan again. This time round the scan will begin from the sector specified in the photorec.ses file.
TIP: Consider using the File Opt option if you only need to recover a specific file format (e.g ZIP, JPG). This will narrow down the amount of files recovered thereby saving you space. This option becomes available right after selecting the target disk / partition for recovery.