My external hard drive has been formatted. No backup on Time Machine. How can I recover my files?
I lent my hard drive to a friend and he has formatted it as he couldn't get his PC to recognise it. I have no Time Machine backUp. Is there any way of recovering this data?
Solution 1:
First step, use a low level tool like dd to make an image of the drive as it exists now, and then stop using the drive. Every second that drive spends connected to a computer (especially a Mac) is a chance for something new to be written to it on top of data you want to recover. All of your recovery attempts should be performed on the image that you make.
Once you have that image, there are a lot of tools you can try to use.
TestDisk can recover the partition table if that was overwritten. If you had multiple partitions, restoring the table will likely magically and immediately "unformat" all except the first one, because all their metadata will still be intact.
The next thing you want to try depends on the filesystem each (or the only) partition had. There are tools explicitly made for unformatting HFS+, various types of FAT, ext2, etc.
If that fails, or even if it doesn't, the final step is to use a tool that will search through the entire drive, sector by sector, and try to put files back together based on their headers. This is prone to failure in cases of fragmentation, but can often recover things that other methods cannot (including deleted files, fyi). I recommend PhotoRec. You might also try some of the Mac-specific tools covered in this article.
Solution 2:
Yes you can recover a lot.
First rule to take care of: don't mount the accidentally formatted disk as read/write
Here is how to proceed. Open a Terminal or xterm
window.
If your external disk is plugged, run diskutil list
and identify from the last column the name of your external disk.
Let's say it is damaged
(in reality it will be something like disk1s0
).
Unmount it:
diskutil unmount /dev/damaged
Mount it back but read-only:
diskutil mount readOnly /dev/damaged
From now on, your damaged external disk can't be corrupted by OS X
(even root
and Spotlight
won't be able to write to it).
Make a disk image of your damaged disk with Disk Utility, and try any software you want on this safe copy.