Recovering Windows files with a Ubuntu CD III: deleted files
August 5th, 2008
Continued from Recovering Windows files with a Ubuntu CD II: getting your files
Introduction
Usually when you delete a file from your computer, the file is still there—its space, however, is marked as available for use. Even if you reformat your hard drive and reinstall Windows (I had a friend who did this by accident, and I used Ubuntu to save her data), most of your data is probably still there.
Assuming you were able to boot the Ubuntu CD and it properly detected your internet connection, you can use a program called Photorec to recover your personal files.
If Ubuntu does not automatically detect your internet connection, and you have access to the internet on another computer, you can download the appropriate two installer files from here and here. Find a way (by USB key or iPod) to transfer them to the computer running the Ubuntu live session, and double-click libntfs10 to install it, and then double-click testdisk to install it.
This may be a bit confusing—the program we want to use is called photorec, but the program we want to install that allows us to use Photorec is called testdisk. Also, the program is called Photorec, but it recovers many types of files, not just photos.
Installing testdisk to use Photorec
First, we’re going to install the program we need in order to use Photorec.
![]()
Click on System > Administration > Synaptic Package Manager. This will open a software management program that will fetch and install software for us.
![]()
Click on Settings > Repositories.
![]()
Make sure all the checkboxes are checked (or ticked), except the CD-ROM source at the bottom. Then click Close.
![]()
At the top-left corner of the Synaptic window, click Reload and wait for the new software package information to download.
![]()
Now that we’ve told the software manager to find all the software that’s available for installation, let’s install it. Click Search in the Synaptic window, in the search box type testdisk, and then click Search in the dialogue window.
![]()
testdisk should appear in the results. Right-click it and select Mark for installation.
![]()
In the Synaptic window, click Apply, and then confirm you want to apply changes by clicking Apply in the dialogue window as well.
![]()
Wait for the software to download and install.
Prepare backup location
![]()
You can use an external hard drive or even internal second hard drive for backup.
For an internal second hard drive, you can access it the same way you accessed the internal first hard drive (the one you’re trying to recover data from).
If the backup location is an external hard drive, you should be able to plug it in and have it automatically appear on the desktop as an icon.
![]()
Go to Applications > Accessories > Terminal
in the command prompt window that appears. This will show you the path to the backup location. In this example, the backup location I’m using is 2.8 GB large, so I must make a note that it is available at /media/disk-2.
In Windows, new drives “mount” (or become available for use) as new letters (D:, E:, F:, G:, etc.). In Ubuntu, new drives mount as folders inside an all-encompassing directory. The top-level directory is slash (/). Inside that directory is subdirectory called /media, which has inside of it another subdirectory called disk-2. That’s where I want to send the recovered files to.
Recovering files with Photorec
![]()
Before you run Photorec, maximize the command terminal window. To run it, you need to run the command
Don’t try to run the command photorec without sudo, as I tried to do earlier in the screenshot.
![]()
Photorec is a terminal program, so your mouse won’t work in it. You can navigate its menus with your arrow keys and then select your choices with the Enter key.
The media you are selecting is the drive you want to recover files from. Then click Enter to proceed to the next step.
![]()
Select the appropriate partition type. If in doubt, select Intel.
![]()
Select to search the whole disk.
![]()
Since this tutorial is aimed specifically at recovering Windows files, you’ll most likely choose Other for filesystem type.
![]()
This is where things get a little tricky. Photorec will assume you want to back up to a folder in Ubuntu’s /home/ubuntu directory, but you probably want to back up to an external drive (in this example, it’s /media/disk-2).
![]()
To go up a directory, go to the double-dot and press the right arrow key.
![]()
Do the same to go up yet another directory.
![]()
Select the drive you want the recovered files to be saved to. In this case, it’s /media/disk-2.
![]()
Once you’ve selected the backup drive, type
for Yes.
![]()
Wait for Photorec to scan for files. Depending on the size of your drive, this could take a really long time. The drive I scanned for this example is only 8.7 GB and took about 15 minutes to scan. If you have a 160 GB drive, well, you do the math.
![]()
When it’s done, you can select Quit.
![]()
Yes, select Quit a third time.
![]()
To exit the command terminal, type
Checking the recovered files
![]()
If you look at the backup drive, you should see a bunch of folders full of recovered files.
![]()
Every folder will have a mix of different file types. Some files will be music files. Others will be Word documents. There will be pictures and text files. All sorts of stuff you may not even care about. The labels will be random, so even though you have your files back, it’ll be up to you to reorganize them and rename them appropriately.
![]()
To get out of the live CD, go to System > Quit.
![]()
Select the appropriate option, probably Restart.
![]()
Wait for the live session to fully end, and then press Enter to reboot after the CD ejects.
![]()
After you reboot into Windows, you should be able to access the recovered files.
Congratulations! You just saved yourself hundreds of dollars, learned something new, dabbled in Linux (Ubuntu specifically), and didn’t give up access to your computer for days or weeks.
You should, of course, always back up your files, but it’s also good to know there are free and easy ways to recover your data otherwise.
If you need any help with this process, please feel free to post a support thread in the Absolute Beginner subforum of the Ubuntu Forums.
August 31st, 2008 at 11:09 pm
I was wondering if these methods would work on a Mac as well.
By the way thanks for all your efforts to assist people like me with limited computer knowledge.
September 1st, 2008 at 2:49 am
Yes, they will work for Mac as well, with a few modifications:
1. If you have an older Mac (Powerbook, iBook), you should make sure to get a PowerPC version of Linux.
2. If you want to boot from CD, you hold down the C key while booting up.
3. If you’re using photorec, the filesystem type is HFS+ (not NTFS or Ext3 or FAT32).
October 5th, 2008 at 12:46 pm
This works great, and saved me thousands of family photos that my wife failed to back up. My only gripe was that the text documents it recovered are somehow full of junk, or are simply misreporting their size. I can take a 162 megabyte file, select all the text in the document, put it in a new document of the same type, and it will be 1k or less. I had over 80 gigs free to recover a 40 gig drive and because of this issue filled the drive. Thankfully I was smart enough not to have it be my drive with the root partition on it, but it was still aggravating. But, it was better than loosing all the files too! Beggars can’t be choosers I suppose.
November 9th, 2008 at 2:10 pm
Thank you so much! Another great easy-to-follow, newbie-friendly guide by The Great Aysiu! :P