Applied necromancy in Linux or return deleted files from oblivion
I think each of us faced a problem when, due to a glitch in the firmware of the camera, camera, PDA, smartphone, or simply because of a special device / dev / hands, the card was formatted, the data was deleted. At one time, I solved this problem quite simply using the Portable version of Ontrack Easy Recovery, but since I have been a user of linux systems for several years, using this unlicensed application through wine didn’t seem kosher, and my thirst for research and adventure required finding a free native analogue for linux systems. The research ended before it even started, as the first line in a Google search led to a set of TestDisk utilities, which I will discuss in more detail below.
And so, TestDist consists of two utilities:
testdisk and photorec;The official site of utilities .
Short description:
testdisk is a powerful utility designed to recover deleted partitions and to restore mbr boot records after program errors, actions of some viruses, human errors (for example, when the partition was simply deleted).
Features testdisk :
Correction of the partition table; recover deleted partitions Restore FAT32 boot sector from backup Rebuild FAT12 / FAT16 / FAT32 boot sector Fix FAT tables
Rebuild NTFS boot sector Restore NTFS boot sector from backup Fix MFT using MFT mirror Finding ext2 / ext3 Backup SuperBlock
Recovery of deleted files in FAT, NTFS and ext2 / ext2 file systems
Copying files from FAT, NTFS and ext2 / ext3 deleted partitions.
photorec is a data recovery utility such as video files, documents, archives from hard disks and cdrom disks, as well as photos (hence the name of the Photo Recovery program) from the camera’s internal memory. The list of file types for recovery is very impressive and can be found here .
Both open source utilities are licensed under the GNU General Public License (GPL). There are versions for linux, unix, as well as for windows platforms.
Most Linux distributions are already included in the standard repository. For debian-based distributions, installation with the command:
In my case, it was necessary to restore photos from the camera’s card after the camera accidentally formatted the card. After inserting the USB flash drive into the card reader and running photorec with root privileges in the console, the utility offered me to select the drive on which I want to recover data.

In my case it will be / dev / sdb .
Next, select the type of partition table on the disk, for most users it will be Intel / PC.

And then we select the entire partition or disk to search for deleted files. Since I needed to recover all deleted files after formatting, I chose to search the entire drive.
After that photorec is required to specify the type of file system in which the deleted files were stored. In this case, everything is simple, select the second item.

And then on the other drive we select the directory where the utility will save the recovered files.

Then press Y and the program starts its work. For a 32MB card, it took her less than a minute.
Now about the results of work:
Honestly, at first I was very doubtful about the abilities of the program. But opening the directory with the results of the utility, I was surprised to find that not only the recently needed 10 photos were restored, but also 110 others, the earliest of which was taken 3 years ago and was not overwritten when the card was later used, although it was formatted card repeatedly.
As a result, we have another victory of good over evil, a happy smile of the owner of the camera, another fact of proof that there is a sea of useful and high-quality opensource utilities.
And so, TestDist consists of two utilities:
testdisk and photorec;The official site of utilities .
Short description:
testdisk is a powerful utility designed to recover deleted partitions and to restore mbr boot records after program errors, actions of some viruses, human errors (for example, when the partition was simply deleted).
Features testdisk :
Correction of the partition table; recover deleted partitions Restore FAT32 boot sector from backup Rebuild FAT12 / FAT16 / FAT32 boot sector Fix FAT tables
Rebuild NTFS boot sector Restore NTFS boot sector from backup Fix MFT using MFT mirror Finding ext2 / ext3 Backup SuperBlock
Recovery of deleted files in FAT, NTFS and ext2 / ext2 file systems
Copying files from FAT, NTFS and ext2 / ext3 deleted partitions.
photorec is a data recovery utility such as video files, documents, archives from hard disks and cdrom disks, as well as photos (hence the name of the Photo Recovery program) from the camera’s internal memory. The list of file types for recovery is very impressive and can be found here .
Both open source utilities are licensed under the GNU General Public License (GPL). There are versions for linux, unix, as well as for windows platforms.
Most Linux distributions are already included in the standard repository. For debian-based distributions, installation with the command:
- sudo aptitude install testdisk
In my case, it was necessary to restore photos from the camera’s card after the camera accidentally formatted the card. After inserting the USB flash drive into the card reader and running photorec with root privileges in the console, the utility offered me to select the drive on which I want to recover data.

In my case it will be / dev / sdb .
Next, select the type of partition table on the disk, for most users it will be Intel / PC.

And then we select the entire partition or disk to search for deleted files. Since I needed to recover all deleted files after formatting, I chose to search the entire drive.
After that photorec is required to specify the type of file system in which the deleted files were stored. In this case, everything is simple, select the second item.

And then on the other drive we select the directory where the utility will save the recovered files.

Then press Y and the program starts its work. For a 32MB card, it took her less than a minute.
Now about the results of work:
Honestly, at first I was very doubtful about the abilities of the program. But opening the directory with the results of the utility, I was surprised to find that not only the recently needed 10 photos were restored, but also 110 others, the earliest of which was taken 3 years ago and was not overwritten when the card was later used, although it was formatted card repeatedly.
As a result, we have another victory of good over evil, a happy smile of the owner of the camera, another fact of proof that there is a sea of useful and high-quality opensource utilities.