Advertisement

TUAW Tip: What to do when a disk goes bad

We've all been there. The external disk you bought three or four years ago, which has been working great so far, starts to click. And it's not a good click ... it's the kind of click that gives you the spinning beach ball of death.

Poopie.

Sounds like it's time to get the data off that disk, and toot sweet, if you pardon my French. You buy a new disk, and you start copying. But then what happens? The Finder throws up an error saying it can't copy a certain file or folder, and it's 20 folders deep in an old archive of client data. The Finder stops the copy, and you have to figure out where the problem is buried, fix it, and try copying again. Meanwhile, seasons pass, civilizations rise and fall, and your fingernails start to grow into your keyboard.

Double poopie.

So what do you do? Believe it or not, the Terminal can be your friend to quickly copy damaged data, and power through disk errors. The data may still be damaged, but heck if it won't try to copy it somewhere safe.

After the jump, find out how to recover your data, and fast.

The first thing to do is don't panic. There are always ways to recover data, and chances are your data is safe. What we'll do is try the simplest options first, and go from there.

Step 1: Do you have a good backup?

No? Well, I'll save my tut-tuts for the end of the article, and you can move on to step 2. If you do, sometimes the easiest option is to restore data from your backup, rather than trying to recover a damaged disk. Of course, replace the damaged disk as soon as you can, and restore your backup to the replacement.

Step 2: Get the disk to mount

First, we have to connect the disk to the computer to do anything to it. If the disk won't mount, the first thing to do is turn it off, disconnect it, and let it cool off. If it's warm to the touch, be patient. Go get a coffee or make a sandwich. Then try again.

If the disk still won't mount, then you may have a different kind of problem. If it's an external disk (like a USB or FireWire disk), then you may have trouble with the enclosure and not the disk itself. For example, one of the ports might be bad, or the power supply could be shot. If you don't mind voiding your warranty, you can crack open the enclosure and see if you can get the disk itself to mount by installing it directly in a computer (like a Mac Pro or G5 tower), or in another enclosure.

If the disk is inside a Mac, and not external, you can try booting the bad Mac into FireWire Target Disk Mode (TDM). To do that, connect a FireWire cable from the bad Mac to a known good Mac. Then, shut the bad Mac down, and start it up with the T key held down. The bad Mac's damaged disk should (hopefully) show up just like an external disk in the good Mac's Finder.

If it still won't mount, see Dire Circumstances below.

Step 3: Buy or find a replacement disk

You will need a spare disk to copy your data onto, so you'll either want to buy or find a disk that is at least the size of the damaged disk. With external disks, it's good to find a replacement disk that's the same connectivity type as the damaged disk: that is, buy another FireWire drive to replace a damaged FireWire drive. Typically, file copying is a faster when the disks connect to the computer the same way.

You'll want to format the replacement disk the same as your damaged disk. So, for example, if your damaged disk is formatted as HFS+ (Journaled), you'll want to erase your replacement disk with the same format. You can use Disk Utility (located in your /Applications/Utilities folder) to do this.

Step 4: Get yourself some Terminal love

With the damaged disk and the replacement disk connected to your computer, start the Terminal. (It's located inside your /Applications/Utilities folder.)

Let's talk a little UNIX first. As far as the Terminal is concerned, external disks connected to your computer are "folders" inside the /Volumes folder on your computer. Crazy, I know! But we'll have to play its little game to get your data safely copied.

So, for our example, let's say your damaged disk's name is Bad Disk and your fresh, formatted, empty replacement disk is named Good Disk. You also must be an administrator on the computer. Cool? Then we're ready to go.

In the terminal, type:

sudo cp -r "/Volumes/Bad Disk/" "/Volumes/Good Disk"

and press enter. When asked, enter your administrator password.

Make sure to add a trailing slash after the name of the source disk, and omit the slash after the name of the target disk.

For those wondering, typing cp -r "old/" "new" will copy the contents of the folder "old" into the folder "new." cp -r "old" "new" will copy the folder "old" inside the folder "new." Also, using the quote marks around the folder names helps if you have spaces in the names of your disks or folders. You can just as easily omit the quote marks, and put a backslash ( \ ) in front of every space in your path to make sure it works.

Or, you can try the excellent Carbon Copy Cloner, which puts a nice user interface on this process. The only downside is that you have to babysit the computer as it copies files. Carbon Copy Cloner will present a dialog when it encounters a disk problem, giving you the option to proceed, or cancel the copy. Using the Terminal method just assumes you want to proceed, so you can go on about your business.

Now, it's just time to sit back and wait. Depending on how much data you have on the disk, it could be minutes or hours until your data is finished copying. If there are errors during the copy, the Terminal will display the errors and the files they occur in, but will continue copying until everything is transferred over. You'll know it's finished when the Terminal presents you with a new command prompt.

Take heart! The hardest part is over. The files it mentions may be damaged and unusable, but at least the rest of your data is safe. At this point, with a good copy of (hopefully) everything, you can try and run a disk utility to try and recover the damaged files.

Step 5: Run a disk repair utility

Running disk repair utilities always comes with the risk of data loss. (It may be slim, but still -- this is your important data we're talking about.)

Your Mac comes with a fair-to-middling disk repair utility, called (strangely enough) Disk Utility. Try selecting the offending disk in Disk Utility and clicking Verify to see if it can find any problems. You can try clicking Repair to see if it can fix any damage found. Chances are, though, if you're hearing clicking from your disk (or other strange noises), it's a physical problem (rather than a logical problem) that a disk repair utility can't fix.

You can also try running other utilities like DiskWarrior, TechTool Pro, or DriveGenius to repair the disk. I know people who swear by each of these utilities, and DiskWarrior has gotten me out of several sticky situations. With a safe copy of your data already in hand, however, you can feel safer about risking data loss to recover any remaining damaged files on the disk.

Step 6: Profit

Hopefully, you've recovered everything you can, and what you can't recover you can live without. Congratulations! If that's not the case, however, we have what we like to call a dire circumstance.

Dire Circumstances

If the disk won't mount, or you still need to recover a file that cannot be copied thus far, you'll probably need to contact a professional. Data recovery professionals can sometimes come to your location for an hourly fee, and perform much the same tasks we just performed in steps 1 through 6. Alternatively, you can send the disk to a data recovery laboratory, like DriveSavers or Iomega Data Recovery.

These options are all very, very expensive. Professionals can charge hundreds of dollars an hour to visit your location. Data recovery labs can charge upwards of a cool grand in recovery fees, replacement disk costs, and shipping. I had to have a 750GB disk recovered in February, and it cost me nearly $1,600.

Even so, your data is recoverable. It's just a question of how much that's worth to you.

The Moral of the Story

If there is a moral to this story, it's that good backups will not only save you time, but possibly large sums of money. Mac OS X Leopard makes this ridiculously easy with Time Machine, so long as you can connect your computer regularly to an external disk. There's no excuse anymore for not having a good backup.

Unfortunately, it frequently takes people a significant data loss experience to learn that lesson. Take it from me, kids, I had a long list of better things to spend that $1,600 on.

Full Disclosure: Iomega, a manufacturer of external hard drives, was a client of mine from 2002 to 2007. Many thanks also to , an Apple Authorized Repair Specialist, for his expert help with this article.