Apple and Mac OS X

Data recovery isn’t expensive

Just read an article about the Snow Leopard upgrade bug that erases your main user account’s data when you log out of the main account.

This snippet made me laugh:

Unfortunately, unless you have a recent Time Machine or other backup, your data may be gone for good—unless you’re willing to pay for an expensive data recovery process. But then again, Ars readers are they sort that have regular backups, right?

I’ve recovered so much data for people over the past two years using a simple free Linux live CD and a simple free data recovery program (Photorec). I guess the “expensive” part is just buying an external hard drive to put all the previously deleted data on after it’s recovered. But an external hard drive is always a good thing to have.

Computers Linux Ubuntu Windows

The Linux Live CD Award

I’ve moved this post to be a page, but I didn’t want to delete the comments associated with this older post.

You can find the page here.

Computers Linux Ubuntu

Photorec saves the day again

Every now and then my friends seem to accidentally have their files deleted. You can read here about last year’s incident. This year, another friend, who keeps her photos on one laptop with no backups had some folders mysteriously go empty. I had no idea how they got deleted, but I assured her we could probably get most of them back. I didn’t realize what it would take, though!

First of all, I had to borrow an external hard drive, since mine didn’t have enough free space to copy over her entire drive. I booted up a Ubuntu live CD and installed testdisk and tried to run

sudo photorec

on the drive. It appeared to work until it got to 1464 files. Then it just froze up. So I stopped it and restarted it. Froze on 1464 again. Clearly something was wrong. So I tried scanning only the unallocated space on the drive and Photorec gave me a segmentation fault error. I knew the drive was probably damaged in some way.

I figured imaging the drive with ddrescue would solve the problem. I ran it overnight and the next day I realized the external hard drive I’d borrowed was formatted as FAT32 and so would not hold a disk image larger than 4 GB. I resized the partition and created a new NTFS partition and ran ddrescue again. There were a lot of bad blocks on that drive in various places. Running front to back and then running back to front, ddrescue took almost 40 hours to image that 80 GB hard drive with bad blocks.

Then it took another four hours for Photorec to scan the imaged drive and recover the photos. I don’t think it ended up getting everything, but it got a lot, and my friend was grateful and felt a little guilty that I’d spent so much time recovering her data. Instead of accepting a thank-you from her, I told her, “Just buy an external hard drive and back up your photos.”

I think it’s human nature to have to learn the hard way. Most people don’t start backing up until they’ve lost important files.

Computers Linux Ubuntu Windows

Recovering deleted files with a Ubuntu CD

Continued from Recovering Windows files with a Ubuntu CD II: getting your files

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.

Click Close again.

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.

Click Close

Quit the software manager.

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


df -h

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

sudo photorec

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 media and hit Enter.

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.

Select Quit again.

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.

Computers Linux Ubuntu Windows

Recovering Windows files with a Ubuntu CD II: getting your files

Continued from Recovering Windows files with a Ubuntu CD I: the backstory

Booting up the live CD
Once you have your Ubuntu CD (or DVD), place it in your CD-ROM or DVD-ROM drive and boot your computer (yes, even if Windows won’t boot—Ubuntu’s functionality doesn’t depend on Windows, so don’t worry). If the CD doesn’t boot, you may have enable the BIOS to boot from CD. There’s usually a key you can press during boot-up to bring up a boot menu and choose to boot from CD. The key itself varies from computer to computer. On some computers, the key is Delete. On others, it’s F2 or F9. On still others, it’s Escape.

Starting the live session

The first thing the live CD will ask you is what language you want to use. Select English or whatever language you think is most appropriate.

From the boot menu, select Try Ubuntu without any change to your computer and hit Enter.

Wait for Ubuntu to load up. This could take several minutes.

Click on the Places menu and select your hard drive. It won’t be called C: or D:. It’ll likely be labeled by the size of the drive. In this screenshot, my Windows drive is 8.7 GB, so I’m going to click on that in order to make it accessible (since the live CD won’t affect the hard drive unless I explicitly ask it to).

You should be able to see the Windows drive as an icon on the desktop now. Double-click that icon to open it (just as you would double-click on My Computer in Windows). Then go to Documents and Settings (Windows XP) or Users (Windows 7).

Double-click on the username of the user you want to recover files from.

Then find the folder you want the files from. In this example, I’m going to My Documents

If you need to go to a subfolder like My Pictures, double-click on that folder as well.

Once you find the files you want to recover, you can copy and paste them to an external drive or even email them to yourself (for most wired broadband connections, Ubuntu will automatically set up a working internet connection).

Yes, you may be shocked that anyone can boot a live CD and access your files, but it’s true. Better you know now and get rid of that false sense of security you used to have. If you have confidential files, you may want to consider encrypting them or not storing them electronically.

The screenshots and instructions are from Ubuntu 8.04 (nicknamed Hardy Heron), but they should also work (with slight modifications) on other releases of Ubuntu or with other Linux versions (or “distributions”) as well.

Continue reading: Recovering Windows files with a Ubuntu CD III: deleted files

Computers Linux Ubuntu Windows

Recovering Windows files with a Ubuntu CD I: the backstory

The problem
What if your Windows installation is suddenly unbootable, you accidentally delete all your files, or the Geek Squad “accidentally” formats your hard drive without asking your permission or backing up your files first? Well, people who have learned from these kinds of experiences will tell you to learn to back up everything. Invest a small amount of money in an external hard drive and back up often.

Yeah, that’s easy to say after the fact. But what do you do now, when you desperately need a file from an unbootable Windows computer? I’ve read a lot of sob stories online from people thinking they need to pay the Geek Squad hundreds of dollars and also part with their computer for days or weeks at a time in order to get their precious not-backed-up-this-time-but-swear-they’ll-be-backed-up-next-time files.

I did a quick Google search on recovering deleted files and found these depressing results:
Geek Squad – Best Buy geek squad irresponsible, erased my hard drive without consent ripoff Deptford New Jersey
Recover deleted files
How to Deal with Data Loss
f-ing pissed
Windows XP Crash Blue Screen
My computer won’t start?

You do not have to part with your computer for days or weeks at a time, pay someone hundreds of dollars, or be a computer genius in order to access your files right away. In the spirit of Why Every Windows User Needs a Linux Live CD, this tutorial with screenshots will show you how you can use a Linux live CD (with Ubuntu as an example, but there are many Linux live CDs you can use—Knoppix, Damn Small Linux, Mepis, PCLinuxOS) to access files from an unbootable Windows installation, and to recover files that have been deleted or that are part of a drive that has been reformatted.

Linux live CD?
I’m not going to go into a whole detailed history of the free software movement, Linux, and open source. You can read the Wikipedia links and find out more yourself. The bottom line is that the solution is both cost-free and legal.

A Linux live CD is a CD that runs an active session (complete with web browser, word processor, disk utility tools, and more) off the CD itself and your computer’s RAM (or memory). It does not affect your hard drive unless you specifically ask it to. Of course, since it is using your RAM and not your hard drive to run the live session, the more RAM you have, the more smoothly the live session will go. For these purposes, I’d recommend at least 256 MB of RAM. If you have less than that, you might want to look into Damn Small Linux or Puppy Linux instead of Ubuntu. They provide a lighter live session that can run comfortably with a small amount of memory.

Getting a Ubuntu CD
Usually, it’s not that hard to get a hold of a Ubuntu CD image if you have a working Windows computer and a broadband connection. Since we’re operating under the assumption that your Windows isn’t booting, there are several alternatives for obtaining a Ubuntu CD:

  • Find a Ubuntu user near you. Believe it or not, you may actually know a Ubuntu user—ask around. Even if you don’t, you can probably find one on Craigslist who’s not only willing but more than happy to give you a free Ubuntu CD. You can also try to contact a local Linux Users Group (they exist in all parts of the world), and the nice folks there will likely give you a CD for free or charge you only a nominal fee.
  • Use another computer to download and burn a copy of Ubuntu. This could be a computer at work or a computer at a friend’s or relative’s place. I’ve detailed here this entire process. It requires a faster-than-dial-up connection, a CD burner, and a blank CD.
  • Buy a CD or DVD. If you don’t know anyone who has a Ubuntu CD, feel shy about asking strangers for one, and have no access to a computer through which to download and burn Ubuntu, you can buy it at a very small cost. For example, Best Buy sells a boxed Ubuntu set for US$19.99, and Amazon sells a DVD of Ubuntu for US$12.99. Unfortunately Best Buy and Amazon don’t appear to sell these any more, but you may find them available on eBay or Craigslist.
  • Order a free CD. As a last resort, if none of the above options work for you, Ubuntu’s company will actually ship professionally packaged CDs to you for free (including postage). The only problem with this method of obtaining Ubuntu is the time it takes (you could be waiting up to two months to get your free CD in the mail.

Continue reading:
Recovering Windows files with a Ubuntu CD II: getting your files