sudo apt-get updatesudo apt-get install testdisk
Recovering files from damaged disk are very simple, especially if you are using Linux! If you don't have a Linux machine, don't worry, you can download a liveCD/liveUSB version from any distro. My suggestion? Get a Ubuntu here: ubuntu.com
Step 1) Get Ubuntu (If you already have Ubuntu or other Linux distro, skip to Step 2)
Once you downloaded the Ubuntu OS, burn it into a CD for a liveCD, or save it into a USB drive for liveUSB. The beauty of a live OS is that you don't have to install it onto your hard drive, for a slower performance, of course.
Okay, now restart your machine and boot using CD or USB. You will be taken into a Ubuntu desktop
Step 2) Now you need a tool called testdisk. There are several ways to get it.
2.1) The easiest is just using the command line in the terminal :)
2.2) The other way is using Synaptic. Click on System>Administration>Synaptic Package Manager or type 'sudo synaptic' in the terminal. Once you have the Synaptic running, search for 'testdisk' and click on the box next to Testdisk. Click Mark for installation, then click on that green tick symbol lebeled 'Apply'.
2.3) The third way is by using Ubuntu Software Center. Click on Applications>Ubuntu Software Center and type 'testdisk' in the search field. Then click Install
Step 3) Using photorec
Inside testdisk package, there's this little but powerful tool called photorec. Open your terminal and type 'sudo photorec'. This will give you a list of disk connected to your PC. The example below is showing my hard drive (ATA) and USB drive (JetFlash)
Go on and select the disk you want to recovery. Use the arrow keys to highlight and Enter key to select. I'm going to select my USB disk.
Now you have to tell photorec which partition type you are using. Select Intel and press Enter
Now photorec will show the detected filesystem on your disk. By default, all USB dan SD drives are using FAT32 system. Select 'Search' and press Enter
Okay, for Linus users, we sometimes format our disk into an extended system such as ext2, ext3, or ext4. But most of the time, we're not. That's because other OS can't read extended filesystem. So here the option is to select 'Other' and press Enter
Next, you have the option whether to search for files in unallocated space, or the whole disk. Obviously we want to search the whole disk. Proceed
Photorec will list all the files and directories in your disk. Press 'Y' key if you want to recover the whole disk, or highlight the directory you want to recover, press Enter, then press 'Y' key. Here I am recovering a directory called R (R-commander is an open-source statistical tool). This directory actually have been deleted from my USB disk last month, but I haven't formatted my disk since then, so now I'm going to recover it.
Once you started the recovery by pressing 'Y', photorec will start looking for files and copying them into the home directory, which is /home/(username)/ . This will take quite some time, depending on how large the size of files your want to recover.
Once the recovery is completed, check in your home directory, the files will all be there.
EDIT: If photorec can't detect your disk, follow the instruction in this post [LINK]