Due to some problems, I tried installing Ubuntu in my machine. But accidentally I installed it in the same partition where my earlier installation was. My data was inside the home directory in the same partition. So all got wiped. Is there any way to recover the data? I am trying to use Testdisk. It is analyzing the disk for several hours. I am not sure how to use it properly. Is it the right tool? Or should I try any other tool?
TestDisk is a much better tool than PhotoRec. However, the only problem with TestDisk is that it doesn't always recover all the deleted files. So, if you accidentally reformat a partition, TestDisk can recover thousands of files without missing a single file, but if you deleted a file by sending it to the Recycle Bin (Trash), and then emptying the Trash, TestDisk might not be able to recover it for you in all the cases.
So use TestDisk first, and if you recovered all of the deleted files with TestDisk, then great, else you can recover the rest of the files using PhotoRec.
PhotoRec can selectively recover files based on their filetype(s), but PhotoRec / TestDisk can't selectively scan an individual directory for lost files unless you had mounted a whole hard drive partition as this directory. In some cases, the filename is stored in the file itself. PhotoRec tries to recover the filename in this case, but most of the time PhotoRec can't recover the filenames.
Here are the steps to recover files based on filetype using PhotoRec:
Install Test disk:
sudo apt-get install testdisk
Launch PhotoRec. Open a terminal and launch photorec (as root):
Select Hard Disk
Select the partition type. If your hard disk has Linux partitions, then select
Select filetype option
[File Opt] and press the Enter key. Here you can disable all file types by pressing s key. Use space to toggle the check button. Select filetype(s) to recover.
- Select options
Photorec also has a list of different options. Under normal circumstances, you don’t need to modify them.
- Select partition
Move the selector up or down to the partition from which you have removed the file(s). Then select
[Search] and press the Enter key
- Select filesystem type
If you are using Linux, it's going to be
ext2/ext3/ext4, so the default selection is
ext2/ext3. Otherwise, if you are recovering files from a partition formatted as FAT or NTFS select
- Select space for analysis.
Free if you didn’t write to that partition after removing the particular file, otherwise select
- Select a directory for the recovered files
Select the path where the recovered files will be stored. Then press Y key
Once done, Photorec will show how many files it has recovered.
Note: Another Forum thread [closed], but it might be able to help you: Recovering Data