I’ve done this twice now, so I thought I would document it for Google’s sake.
first, dd the drive
Use Disk Utility to find out the /dev/ name of the disk (/dev/disk0s2, /dev/disk1, etc). Click the disk and hit ‘Info’ to get its name.
sudo dd if=/dev/diskname of=outputfilename.dmg conv=sync
the conv=sync bit makes it put zeros where it can’t read the data.
It will take a long time. The more messed up the disk, the longer it will take. You can use the Finder to see how big your .dmg file has gotten and compare that to the disk size for a very rough estimate.
When done, do:
sudo hdiutil attach outputfilename.dmg -nomount -readwrite
it should spit out a new pseudo-device name, like /dev/disk3, for your thing.
You may be able to get DiskWarrior to run on that pseudodevice (though I had trouble, but that was because my disk image was itself on a bad disk(!)). or you can use:
sudo fsck_hfs -f /dev/pseudodevname (-f forces it if it has a journal)
when done, detach using
hdiutil detach /dev/pseudodevname
Now try mounting the disk. If you’re lucky, it worked.
The restore can be done with Disk utility – choose source, and destination (and for fast and friendly block copy, choose ‘erase destination’).
I do command line, usually, so I try to use:
sudo asr restore --source diskimage.dmg --target /dev/newdisknum --erase
Bryan asks me how he can see if his disk had errors – make that ‘conv’ bit in the dd line to be conv=sync,noerror and then dd will spit out a couple of lines every time it fails to read data. Not 100% sure on that, check the man page for dd.
I’d like to amend my method up there – definitely do the ‘noerror’ part, because it goes fast or slow depending on whether its hitting a yucky disk part or a good one, and it’s good to have an idea of where it is, and where it’s getting stuck.