There are plenty of recovery applications, personally I find that and photorec work best. Photorec is part of the foremost package, foremost can be installed from the testdisk package.foremost
a) Photorec
Simply run now to open up photorec's interactive interface.$ photorec /dev/sdb
Hit return () to select the disk. In the next screen, you're asked to select a partition. If photorec finds the correct partitions, you can select the one you want to recover the files from here. If it doesn't detect the partitions properly, simply select [Proceed] and hit return again to perform the No partition [Whole disk]. Once selected the filesystem type in the next screen, you need to select a directory in which the recovered files should be saved. Confirm with [Search].C
b) Foremost
While photorec works by trying to find "data blocks" of the drive and media within using file carving, foremost does it a bit differently. It's still using the file carving concept but it ignores the type of underlying filesystem and directly works by copying segments of the drive into your RAM, which is then being scanned for file header types. Foremost comes with a lot of built-in headers to recover most types of common files, if you want to add custom headers/footers to detect less common file types, foremost offers you this ability.
To run foremost using the default options on the image, run the following command:
$ foremost -i /dev/sdb -v
You can use here if you want to recover files from only that partition./dev/sdb1
That will save all recovered files into (new directory that foremost will create). You can specify another output directory using the output flag, and -o to ignore errors/save corrupted files.-a
This is optional, but sometimes you are only interested in specific types of files, or even worse: Recovery tools give you a million of files out of which thousands appear to be, for example, a JPEG file, but in reality it's just a corrupted file and not a picture at all. To filter these out you can use this answer I gave to another question on SuperUser.
I see people messing their data up with way too often. It's just too easy. My recommendation:dd
#!/bin/bash
read -r -p "Have you checked at least TWICE if the parameters are correct? [y/N] " response
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]; then
dd "$@"
else
echo "Better be safe than sorry."
fi
Save this as or whatever name you'd like. /usr/bin/sdd it afterwards. From now on, always use chmod +x instead of sdd.dd