Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Recover a dead hard drive using dd UNIX
The Unix program dd is a disk copying util that you can use at the command line in order to make a disk image. It makes a bit-by-bit copy of the drive it's copying, caring nothing about filesystem type, files, or anything else. It's a great way to workaround the need for Norton Ghost.

Normally, in order to make a disk image, the disk you're copying from has to be able to spin up and talk -- in other words, it's OK to make a copy if the disk is healthy. But what happens when your disk is becoming a doorstop? As long as it continues to spin, even with physical damage on the drive, dd and Mac OS X will get you out of the fire.

We had a situation recently where a friend sent a disk to us that had hard physical errors on it. It would boot in Windows, but then it would hit one of these scratch marks and just die. We fired up dd, and it started OK, but stopped at the same physical error location -- complaining about a Hard Error.

So the workaround was to designate the dd mode as noerror -- which just slides over the hard stops, and to add the mode sync, which fills the image with nulls at that point. We did it on BSD Unix, but as long as you can get the hard drive attached to your Mac, the command is the same:
dd bs=512 if=/dev/rXX# of=/some_dir/foo.dmg conv=noerror,sync
The bs=512 designates block size, and the if=/dev/rXX# is the UNIX path to the actual disk device. Make sure that the chosen directory (some_dir) has enough room to take the entire disk image -- which will be equal to the size of the drive. Since dd doesn't care about the contents of the drive, it copies every bit on the thing, so you get an image equal to the disk's capacity. A really big file. One workaround is to put it on a RAID array.

Once you've established the disk image (in this example, foo.dmg), you're almost home. Here's where your Mac OS X box is far and away the best thing to have. In this example, the dd output file is foo.dmg. You have to realize that this is an exact copy of a busted drive, but the "holes" are filled with nulls. As long as the damage isn't to the boot sector, though, when you double-click on it, Mac OS X mounts it without breathing hard ... who cares if it's FAT32, NTFS, whatever.

Due to the size of the image that we were copying, we put it on a RAID array, and had to access the image over the network -- it still mounted fine. In straight UNIX, if you try to mount a disk image, it complains that there is "no block device" and fails. Once your image is mounted, it appears in your Finder, and then it's easy work to retrieve the critical files from the image -- usually things like .doc files and .xls files and the lot.

Finally, since your disk is actually dying, once you have your image, you can drop it to tape or something and you've not only recovered your files, you've made a viable backup as well. Once again, that which destroys a Windows box becomes a play thing to a Mac OS X box.
    •    
  • Currently 3.20 / 5
  You rated: 3 / 5 (25 votes cast)
 
[461,677 views]  

Recover a dead hard drive using dd | 76 comments | Create New Account
Click here to return to the 'Recover a dead hard drive using dd' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Recover a dead hard drive using dd
Authored by: daybrother on Mar 04, '05 10:26:00AM

This is the best hint I have ever seen. Thank you.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: simonpie on Mar 04, '05 08:53:46PM

I so agree !!!



[ Reply to This | # ]
permission Denied Problem
Authored by: roynel-parnelly on Mar 15, '06 08:19:29AM

Hey I'm trying to work this out but no matter how I try to type inthe command. I get "Permission Denied" as the response from the terminal. I even tried going into the netinfo manager and enabling "root user" on the machine. I should point out that I'm trying to copy the disk image to a networked drive. Does this make a difference???

any pointers on what I may be doing wrong?



[ Reply to This | # ]
permission Denied Problem
Authored by: hagbard on Sep 27, '06 02:00:21PM
you probably need to have root privileges, try putting 'sudo' before the command, ie :
sudo dd bs=512 if=/dev/rXX# of=/some_dir/foo.dmg conv=noerror,sync

[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: signal15 on Mar 04, '05 10:55:10AM

I have been using this method for awhile, however, I stopped using the sync option. They sync option made it so I would have files that were totally unusable. Without the sync option, I end up with everything readable. Does dd try to re-read the data until it gets it if you don't use sync? That's what it seems like.

Without the sync option, the dd copy takes WAY longer, so I assume it keeps going over the same spot until it gets your data.

I lost 2 drives on my powerbook in the last 4 months, and dd saved my azz. :)



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: melo on Mar 04, '05 11:10:41AM

Much better: check out dd_rescue and it's frontend dd_rhelp.

I recently had hard drive problems and with those two utilities I could restore most of my hard-drive (lost 12kbytes).

dd_rescue: http://www.garloff.de/kurt/linux/ddrescue/
dd_rhelp: http://www.kalysto.org/utilities/dd_rhelp/index.en.html
my rescue day: http://www.simplicidade.org/notes/archives/2005/02/recover_day.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: pelooyen on Dec 05, '05 04:09:06AM

sorry for being a newbie, but how does one compile ddrescue? I am desperately tryig to recover a dead WD. I have 10.2.8, but also Tiger on a laptop



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: melo on May 05, '06 02:51:21AM

Compiling dd_rescue worked for me out of the box. the following commands did the trick.

curl -O http://www.garloff.de/kurt/linux/ddrescue/dd_rescue-1.11.tar.gz
tar zxf dd_rescue-1.11.tar.gz
cd dd_rescue/
make

This will compile dd_rescue 1.11, the latest version at the time I write this. Check the homepage to see if there is a more recent version.

You need the Apple Developer Tools, freely downloadable from the Apple Site.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: bitzar on Feb 06, '06 10:14:21AM

I've been trying to use dd, dd_rescue and dd_rhelp for about 6 days now to recover an 80GB NTFS drive through OSX on an intel iMac.

The drive always gets to one of 2 points (1.44GB or 4.5GB) and stops responding. The hdd's active light does not indicate any activity and the control c will not stop the program. If I were using dd_rhelp, this is where it would write the log file.

The -r option on dd_rescue does not seem to work to make the job run in reverse, it runs and then finishes the job quickly without copying any data.

The start position parameter does not seem to work either. The dialog immediately following the the command reflects that I entered a start position but the drive still works through from the beginning and pauses at 4.5gb instead of just starting at 5gb.

Did you have a need to experiment with these options? Is there any advice you can provide?

It's been awhile since this poster posted originally, does anybody else have any advice?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: melo on May 05, '06 02:53:31AM

Hi,

I did not need to deal with any parameters. I guess I was lucky. I would try the -r but apart from that I sorry I can't help you further.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: stephensan on May 10, '06 10:39:58PM

Melo (or anyone else),
You seem to have a relatively good grasp on dd_rescue... so I offer you my question.

I was able to use Darwin Ports to successfully install dd_rescue on 10.3. Everything looks great, but... when I run it with this command:

dd_rescue -v /dev/disk3s10 /dev/disk2s10/

I get this error:

dd_rescue: (fatal): open "/dev/disk2s10/" failed: Device busy

disk3s10 is my bad external drive (115 Gb)
disk2s10 is my good external drive (229 Gb)

disk2s10 is a clean partition, on a brand new drive (2 partitions total)

I feel like I've searched everywhere, yet I still can't figure out why I'd get this error.

Thanks in advance for any help you can offer,

Stephen




[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: Superboy on Jul 24, '06 04:11:43PM

I think you need to put a filename at the end of the path:

dd_rescue -v /dev/disk3s10 /dev/disk2s10/mydisk.dmg

Otherwise it's trying to overwrite the whole of your disk3s10 disk...

Hope that helps!



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: dgchichester on Mar 04, '05 12:19:48PM

Regarding:

The bs=512 designates block size, and the if=/dev/rXX# is the UNIX path to the actual disk device.

How would you determine the UNIX path to the disk device?

I have an old desktop drive that got hammered during the transition from System 9 to 10 some time back, and I've always held on to it in hopes of finding a way to "get at it." I can hook it up to a firewire case and plug it into my functioning system that way, but what would be the UNIX route for such a connection?

Thanks in advance.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: electricferret on Mar 04, '05 01:03:52PM
In OS X you can use the "disktool" command to find out what disks you have connected. Try
disktool -l
to get started. I don't know how you would do this on other Unixes - it varies by system, as does the disk naming convention.

[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: burro on Mar 06, '05 12:01:56AM

disktool lists them as

..
**Disk Appeared ('disk1s1',Mountpoint = '', fsType = '', volName = '')
..

the suggested command has a format

rXX#

Which one is it?
------------------------
PS. UNIX such a nice idea so sloppily implemented.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: hagbard on Sep 27, '06 02:06:17PM

disk1s1 !
another way to see this list is to type df, which lists all disks and their data usage. To see the data sizes in KBytes, type :
df -k
the first column is the reference you need.
To be more informative :
diskAsB means :
disk number A, partition number B



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: burro on Mar 06, '05 12:11:14AM

disktool lists them as

..
**Disk Appeared ('disk1s1',Mountpoint = '', fsType = '', volName = '')
..

the suggested command has a format

rXX#

Which one is it?
------------------------
PS. UNIX such a nice idea so sloppily implemented.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: electricferret on Mar 07, '05 01:03:42PM
It depends on what OS you're trying to read the disk in, really. (See your sig for details. :))

On OS X, you use what disktool reports, but put a "/dev/" in front of it. FWIW, I found that I had to read the whole disk to get it to work, not just a single partition. YMMV. The full disk is the "diskX" name, and the individual partitions on it are the "diskXsY" names. All together, this means on OS X you're going to get a device path like:

/dev/diskX
The "rXX" device name is for the author's BSD system. On a Linux system, you'll get names like "hdaX". (And Sun and HP and every other system have yet other naming conventions.)

[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: peragrin on Mar 04, '05 01:07:37PM

I can't tell you the exact location of the unmounted drive. The easiest way is to hook it up to the enclosure and try to let OS X mount it. If it fails, You can use Diskutil to determine the /dev location of the drive.

There Is a commandline version of diskutil as well. just type man diskutil, into either the command line or google. If you are trying to figure out how to use a commandline tool and don't like man pages, you can use google to pull up html versions.

Just remember this creates one file the size of the formatted drive. so if it was 20gigs you have about a 20 gig file.

I never did a system 9 to OS X transition. I do know both used the same file system. So you have a good chance at getting data.

---
I thought once I was found but it was only a dream



[ Reply to This | # ]
Disk Utility
Authored by: lullabud on Mar 04, '05 01:48:19PM

When you open Disk Utility it gives you a list of physical disks attached to the computer and their related partitions. If you click on the physical disk and hit "Info" it will show you the "Disk Identifier", such as disk0, disk1, and so on The number increments as you attach more physical disks to the system. If you click on a partition you'll see that you get a Disk Identifier of disk0s3, disk0s4, or so on up with the second number. I don't know why it starts at 3, but it does, and it goes on up from there. (I just partitioned a disk into 6 partitions to check this.)

So, to apply this practically, you would plug in the disk that is corrupted and check its identifier in Disk Utility. If DU can read the partition table it will assign the "s#" to it, even if it can't mount it. You can then go into terminal and put this in place in the dd command listed in the hint.



[ Reply to This | # ]
Actually...
Authored by: lullabud on Mar 04, '05 01:56:06PM

The partitions seem to go up in odd numbers, and the disks aren't always consecutive. I have 4 disks attached right now and they are 0, 1, 3, 4. At any rate, the way to find the information is right.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: obiwan2u on Mar 07, '05 01:30:10AM
dgchichester asked:
How would you determine the UNIX path to the disk device?

The df command seems to list this info (see the left hand column, first row of data):


Filesystem    512-blocks      Used    Avail Capacity  Mounted on
/dev/disk0s5   120093120 108689400 10891720    91%    /
devfs                193       193        0   100%    /dev
But I'm not sure if this is the right device name. When I try and copy from it using dd, I get a "device busy" error.

Do I have to boot from a CDROM to make a disk image copy of my normal boot disk?

PublicMailbox at benslade dot.com

---
Put 030516 in the email subj to get mail thru to me.

[ Reply to This | # ]

Recover a dead hard drive using dd
Authored by: TyHuffman on Jul 10, '05 08:42:25PM

Go to the Apple, upper left hand corner and select the about this Mac from the menu. When it pops up select more info... there you will see all of the different hardware buses or interfaces, for a HD select ATA, look for the Mount point towards the bottom. FireWire is the same way, you will see all of the attached devices and they will have a mount point. That is where you will find the address which is the Mount Point.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: electricferret on Mar 04, '05 01:13:59PM

This is a great hint and I'm preparing to rescue a failed PowerBook drive like this, but how do you get the drive connected to a Mac in the first place? I've put my dead drive in an external USB enclosure, but when I plug it into the Mac, OS X insists on trying to mount the drive. Since the disk seems to have errors in the volume definition areas, this fails and eventually the drive just spins without reading. OS X never mounts it and I can't do anything with it.

I tried the same on an old Linux box, but when reading the errored parts of the disk, the USB ports froze and Linux now refuses to recognize a drive there at all (short of powering down).

Is there anyway to prevent OS X from mounting a drive when you connect it?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: burro on Mar 06, '05 12:44:58AM

I put mine in FW enclosure. It never mounts. Depending on the phase of the moon, the fire wire bridge chip will reported it as a unformatted drive or will refuse to work with the disk at all. In the latter there is no way you can use this scheme in ext. enclosures at least. Put it back in the original machine, boot it up from external and try again.

OS X will see the disk, mounted or not. Issue

disktool -l


With my failed FW enclosed drive hooked up I got two new entries

***Disk Appeared ('disk1',Mountpoint = '', fsType = '', volName = '')
***Disk Appeared ('disk0',Mountpoint = '', fsType = '', volName = '')

(for ref here is my bootup system disk mounted,
***Disk Appeared ('disk0s9',Mountpoint = '/', fsType = 'hfs', volName = 'System')

To decide which one is it (don't you hate UNIX for its unbelievable sloppiness?) go to Disk Utility, select your disk and using contextual menu (right mouse click) get Information. In my case FW enclosure was disk1.

Issue
dd bs=512 if=/dev/disk1 conv=noerror,sync | gzip -9 > foo.dmg.gz
to read that disk in. You should see some activity on that drive. Reading may take forever as internal disk microcode will try to read every failed block numerous times.



[ Reply to This | # ]
How long will it take?!
Authored by: masthugget on Mar 07, '05 03:27:09PM

And with "forever" you mean?

I started a dd-session to make a disk image of my 60GB drive in my iBook and it has so far only copied 110MB in 85 minutes. At this speed it will take some 30 days to complete!

Can this be right?



[ Reply to This | # ]
How long will it take?!
Authored by: electricferret on Mar 07, '05 04:41:24PM

Depending on the number and severity of errors on your disk, absolutely. 30 days might even be optimistic. In reality portions of your disk are probably still good and will read very quickly, but the errors slow the whole process down.

You might want to read the man page for dd, especially the "skip" and "count" options. Instead of reading the whole disk in one pass, you can read parts of the disk into several files and cat them together later. Of course this means you need twice the disk space of the original to reassemble the rescued image in.



[ Reply to This | # ]
How long will it take?! / Done, but it won't mount!
Authored by: masthugget on Mar 08, '05 01:14:14PM

Just as you said, it was only certain parts of the drive that took that long, the rest went much quicker. It's ready now.

But now to another, more severe?, problem. I cant mount the .dmg file! When I try I get an error message saying that it can't connect to the filesystem (translation from swedish).

Any ideas?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: DeminJanu on Jun 25, '09 05:44:02PM
btw, the terminal command df -k will list the UNIX device name along side the actual mount point (aka. the "real name" for us human beings). Of course the Root drive doesn't have a real name, it's just /
eg.
[me@mycomputer:[~]$] df -k
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/disk0s2 184408240 182249088 1903152 99% /
devfs 120 120 0 100% /dev
fdesc 1 1 0 100% /dev
/dev/disk0s3 10475512 577448 9898064 6% /Volumes/WINDOZE
map -hosts 0 0 0 100% /net
map auto_home 0 0 0 100% /home
/dev/disk2s3 312440112 287359576 25080536 92% /Volumes/Chronos
/dev/disk3s1 244136352 201556960 42579392 83% /Volumes/MELCHBACKUP
/dev/disk1s1 312492320 308901888 3590432 99% /Volumes/DEMBAK


[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: bvtn26 on Nov 20, '05 12:36:55AM

If you are running 10.3.x you can disable the diskarbitration daemon to prevent devices from being mounted. Simply rename disarbitrationd to something easy to remember and reboot. Just change things back when you are done.



[ Reply to This | # ]
Save Space with Gzip
Authored by: lullabud on Mar 04, '05 02:00:20PM
If you're limited on local space you can use a pipe to gzip instead of the "of=" option.
dd bs=512 if=/dev/rdisk2s3 conv=noerror,sync | gzip -9 > foo.dmg.gz


[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: Zeitkind on Mar 05, '05 10:09:43PM

You can mount most images on newer unix-systems if they support loopback-devices. Just google for lofi and lofiadm.



[ Reply to This | # ]
How long will it take?!
Authored by: masthugget on Mar 07, '05 03:35:06PM

I started a dd-session to make a disk image of my 60GB drive in my iBook and it has so far only copied 110MB in 85 minutes. At this speed it will take some 30 days to complete!

Can this be right?



[ Reply to This | # ]
rdisk0 or disk0?
Authored by: masthugget on Mar 08, '05 01:37:45PM
I can see people are both talking about rdisknn and disknn as identifier for the faulty disk. In the disk utility it says (for me) disk0, but under /dev/ I find both rdisk0 and disk0. What's the difference, which one should be used?

[ Reply to This | # ]
rdisk0 or disk0?
Authored by: bvtn26 on Nov 20, '05 12:43:06AM

rdiskxx is the raw device and diskxx refers to the same device as a block device. I believe you can use either. I prefer using rdisk from a forensic standpoint.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: aerodr on Mar 24, '05 01:46:39PM

I've tried this hint both with and without the sync option as suggested by the orginal poster and signal15 on a corrupted drive that contains Redhat 7.0 and Windows 2000 partitions. The resulting .dmg files are the expected size, but when I try to mount the images, a window pops up stating that the image failed to mount because there were "no mountable file systems".

If I run hexdump -C on the .dmg files, I can see some of the filenames on the corrupted disk, so I think the image has the data I want, but mount isn't working.

Anyone have any ideas?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: verypuzzed on Mar 31, '05 12:14:33PM

Similar problem here, I have a drive that contained BeOS and FAT32 partitions, and I "DMG"ed it using OS X.3 Disk Utilities by creating an image from the device. My intention was to get a carbon copy of my drive in order to restore it later, but the Disk Utilities will not accept to restore it (even though the image is being restored to the hard drive it was first taken from). The DMG format (created by Disk Utilities) is probably not a byte-for-byte dump of the drive (i've tried "dd"ing it back) and there dos not seem to be any utilities out there that can reproduce the raw image of my drive out of the DMG file.

If anyone has any ideas on how to proceed, I'm (desperately) open for suggestions!



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: SliqLinux on Apr 01, '05 11:11:36AM

I must say that this hint is pretty cool. I have a RAID box "eRaid" to be exact that contains a few Gigs of data. For some reason the drive refuses to mount, i've tried using disk utility to repair it, tried data rescue x, and disk warrior, none of these work so i used the dd command. It creates the disk image but whenever i try mounting it, it gives me an error "no mountable file systems". I was wondering if there was any way that the data from the disk image could be extracted and placed in a working image. Can anyone help, any suggestions would be great.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: jeffdoto on May 10, '05 04:41:34PM

Hey Guys,

I've followed the instructions as posted, and I can't seem to get my powerbook drive (mounted via firewire target mode) to copy onto my G5. here's the syntax I used:

dd if=/Volumes/jeff of=/Users/kenanderson/Desktop/Jeffs\ Stuff\ Do\ Not\ Erase/jeff.dmg

where "jeff" is my powerbook HD and the rest is the G5 desktop directory.

I keep getting "operation not permitted". I tried using "sudo" to override any privlege stuff, but, no dice.

Any ideas? I thought this was one of the coolest posts I'd seen, and I was psyched to try it, but I crashed and burned. I'm not a seasoned UNIX fella, so take it easy on me.

Thanks in advance,
Jeff



[ Reply to This | # ]
use the device file, not the mount point
Authored by: juz10mac on May 10, '05 06:35:53PM
You are using /Volumes/jeff for your in file. This is the mount point of your volume (where its files can be accessed), but is not the device file. Use the command 'df' to see where Jeff is mounted. It should be something like disk1s3 or something. Use the command
dd if=/dev/disk1s3 of=~/Desktop/Jeff.dmg conv=noerror,sync
(assuming disk1s3 is the device file for jeff. It will most likely be something different).

[ Reply to This | # ]
Recover a bad block file using dd
Authored by: macwebmac on Aug 10, '05 12:52:49PM

This is great tip, that I used to recover file with bad block, to new file.

One mpeg 400MB 20min file on my harddisk couldnt be copied or opened. Always returned error. I used command recomanded, but not on whole harddisk but only on file.

in terminal I put

dd bs=512 if=/Volumes/HD1/badfile.mpg of=/Volumes/HD2/newrecoveredfile.txt conv=noerror,sync

/Volumes/HD1/badfile.mpg is location of bad file
/Volumes/HD2/newrecoveredfile.mpg is new recoverd file path

Sync in file was not lost cos recovered file was padded with zeros where bad block was. New file out of 20mins only had 15frames in bad block, and resulting recoverd mpeg only had 15frames freezed picture.

Great tip!!!
Thanks








[ Reply to This | # ]
Recover a bad block file using dd
Authored by: macwebmac on Aug 10, '05 01:12:43PM

dd bs=512 if=/Volumes/HD1/badfile.mpg of=/Volumes/HD2/newrecoveredfile.mpg conv=noerror,sync


you want same file extension as original, but you can put any nam, and change later in finder



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: DuallyG5 on Sep 05, '05 10:13:43AM

I amin desperate need of this app since my HD is unmountable and I need to get the data off, but how do I compile this or can someone mail me the app or something ?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: h0zae on Sep 12, '05 01:22:25AM

open up terminal, built into osx



[ Reply to This | # ]
Help! am I doing something wrong?
Authored by: joshMV4 on Sep 15, '05 01:19:42PM
I would like to use this hint to attempt to get back some bad data on my dvr's hard drive. It crapped out on me about a month ago. This sounds like the right tool, because the dvr hard drive is an unkown format an unreadable file system by my mac. (1GHz G4, OS 10.4)

Before I tried the bad drive (120GB), I installed a smaller working 10GB drive into my DVR and recorded a few minutes. Then I removed the drive and installed in my mac. I typed the command and 45 minutes later I had a 10GB disk image on my computer. OS X still couldn't mount it, though. I formatted the 10GB hard drive to "erase" the dvr contents, then used dd again to go back from the dmg file to the hard drive. It appeared to be working, but it didn't finish within an hour so I went to bed. By the next morning, it was finshed. I stuck it in my DVR and it worked!... My dvr read the show I recorded previously.

Excited I might have a fix for my bad drive, I installed it into my computer the next morning an repeated the command for the faulty 120GB drive. It qickly made a 10MB dmg file and the terminal said something like "input/output error" 77000 bytes read, 77000 bytes written, then it would freeze up my mouse with the spinning beach ball.

I restarted my machine with a hard power off and back on and tried again. The same thing happened 3 more times, doing a hard power off and back on (this has now locked up my mac more times in 10 minutes than I have had in the 2+ years I owned it). The last time I let it go all night (still not done) and all day at work to see if maybe it is working, just not letting me multitask. I haven't been home yet to see.

Any thoughts? When I first inserted the disk, OS X wanted to initialize the "new" hard drive, so the "bad" hard drife is somewhat functional....

[ Reply to This | # ]

Recover a dead hard drive using dd
Authored by: deanburchell on Oct 20, '05 12:47:11PM

I'm such a newbie when it comes to using the CLI. Somehow I managed to download and compile dd_rescue and dd_rhelp. I even got it running. Unfortunately, it's stalling out after just 350MB of a 150GB (17GB used) drive. Should I assume that if the progress stats aren't changing that there is an irrecoverable problem with the drive and that the process has 'crashed' or should I let it continue? Please help, I was trying to save someone's data from a motherboard defective iBook and somehow the firewire drive I transfered their 'life' to is suddenly unusable. I thought the dd process was the solution as the 3rd party drive tools all failed. (In very much the same way).



[ Reply to This | # ]
Full backup with dd to fat32 external
Authored by: shamael_2097 on Nov 05, '05 02:54:45PM
Hallo, I was trying to backup my powerbook to a FW fat32 formatted hard drive when I came across this... Would dd work in creating a perfect backup of my internal hd that can be restored in case of problems yelding a working OS? Also, I'm kinda new to unix so would a command like this, run from a live-cd after the /dev/zero cleanup, do the job?
 dd if=/dev/hda# | gzip -9 | split -b 4096m /dev/sda#/somedir/macosx 
and to restore:
 cat /dev/sda#/somedir/macosx* | gzip -d | dd of=/dev/hda# 
In the hint the block size is specified, does it depend on source or target disk?

[ Reply to This | # ]
Will this work if the drive wont mount?
Authored by: TheLoneRoger on Jan 17, '06 07:36:49AM

Am I right in thinking that if the disk wont mount, you can't get a file path from disktool and therefore can't use this method ?
I have a (dead) drive that appears to be spinning but I can't get it to mount. It seems to be stuck in some kind of loop, making a rhythmical clicking sound which might be interesting were it not for the fact that i want the data off that drive!
Is there any hope for this drive...?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: barrysharp on Mar 15, '06 06:58:32PM

NB. The dd command is very very slow. For example on my PowerMac with 4.5 GB RAM it ran at about 8 MB/s to my 3x RAID 0 and so for dd-ing my 300GB boot device it would take some 12 hrs to complete.

Also, you can use kill -s SIGINFO dd_pid to get dd to spit out its progress. This could be useful for the long running dd process.

I suspect dd could be useful in other ways such as reporting areas on the disk with unrecoverable read errors.

BTW - Thanks for posting this hint.

---
Regards... Barry Sharp



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: barrysharp on Mar 16, '06 06:45:30PM

BTW - what makes the dd bs=512 so slow is the block size (bs) od 512. Increase it to 51200 and speed will dramatically increase.

---
Regards... Barry Sharp



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: whawha on May 26, '06 03:20:17AM

Thank you very much for posting this hint. I have a dead ext firewire hd with a lot of data that I need to recover. The disk still spins, but will not mount - a grating noise makes me suspect that there is damage to the head that reads the disk.
I'm pretty desperate to recover this data, unfortunately my knowledge about Unix and related topics is complete zero. Could somebody kindly guide through the process? I went to the ddrescue download page
http://www.garloff.de/kurt/linux/ddrescue/ and I dont even know which file to download to get started.
I'd be very, very grateful if someone could help me with this.
Andrea



[ Reply to This | # ]
Slows transfers and unmountable images
Authored by: snowleo on Jul 19, '06 12:07:44PM

With block size at 512 and using sync, I was getting 0.5mb an hour - ie 20 days to recover a 250gb drive. Block size at 51200 and without the sync option will yield a more reasonable 12h to copy off the defunct drive.

After creating the dmg (which was from a linux not a mac drive), I did find the resultant file unmountable. FileSalvage (from subrosasoft.com) for $79 was able to scan the disk image and recreate the file list.... unfortunately with all the filenames missing :). It does at least sort by file type so you can sort of narrow the window for the file(s) you are looking to recover if you have experienced the same level of drive damage.

Thanks for the advice on dd. Hope the above helps re slow copies and unmountable results



[ Reply to This | # ]
another useful article
Authored by: andrei.railean on Jul 22, '06 04:49:38PM

Another article on recovering drives using ddrescue (NOT dd_rescue and dd_rhelp) is here:

10.4: Recover a dead hard drive using GNU ddrescue



[ Reply to This | # ]
another useful article
Authored by: kwanghui on Oct 22, '06 05:54:10PM
gnu ddrescue is fantastic and has helped me recover critical data on many occasions.

To add to this:
1. it also works with floppies and cdroms. i have used it to recover data from floppies with mould growing and damaged by water, from cdroms that were scratched, etc.

2. the "--reverse" option is often quite useful as it allows you to read backwards from the end of the media. I have found this useful with scratched cdroms, as well as some hard disks with bad sectors. in addition you can define an offset to start seeking from, using the "skip" option

3. this website has some useful info clarifying the difference between dd_rescue, ddrescue and dd_rhelp
http://www.toad.com/gnu/sysadmin/index.html#ddrescue


[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: rSm00th on Oct 22, '06 01:41:50PM

I had two 20gb Maxtor drives in a RAID 1 setup both crap out on me at the same time. I tried replacing the logic board on one of the drives with a matching one but they both give the "click-o-death" at bootup.

Mac OS sees the drive and it shows up as /dev/rdisk1, and I'm trying the DD method about to copy a disk image. DD is showing a "device not confiugred" error as it's working, so we'll see how it works when it finishes up.



[ Reply to This | # ]
Directory path for dd
Authored by: cfh on Mar 27, '07 02:21:14AM

I'm trying to recover from one external drive to a second, both connected to a Mac. I'm getting a directory error message on the output file drive. Several of the drive paths I've tried are listed below.

dd bs=4k if=/dev/rdisk2s2 of=/dev/rdisk1s3/buimage.dmg conv=noerror,sync

dd bs=4k if=/dev/rdisk2s2 of=/dev/disk1s3/buimage.dmg conv=noerror,sync

dd bs=4k if=/dev/rdisk2s2 of=/dev/disk1s3/recover/buimage.dmg conv=noerror,sync

All list the of drive with the Not a directory message, e.g.
dd: /dev/disk1s3/recover/buimage.dmg: Not a directory

The drive names are correct (listed with df -k):
/dev/disk1s3 312440112 96204 312343908 0%
/dev/disk2s2 160823792 120768544 40055248 75%

The buimage.dmg file does not yet exist. I did create a directory called recover. The of drive contains only that directory (empty) and some backup software that came installed on it.

Thanks for any help anyone can offer.



[ Reply to This | # ]
Directory path for dd
Authored by: pjx on Dec 01, '09 06:55:24PM

Did you ever get this to work. I am in the same boat you were and cant get past it.



---
http://www.jbtvonline.com/gallery/wristm.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: bugmenot on Sep 02, '07 05:10:59PM

"Once again, that which destroys a Windows box becomes a play thing to a Mac OS X box."

Did Apple invent dd? Or could we just say that when you've found an extremely useful command line utility, chances are it was created by the open source community.



[ Reply to This | # ]
Got the image OK, but get "no mountable file systems" msg
Authored by: ckbarlow on Oct 09, '07 05:31:30AM

I used dd overnight to copy a suddenly unmountable 120GB drive to a directory on a 500GB drive. The resulting DMG file shows up fine.

When I double-click to mount the image, though, I first get a "file may be damaged; do you still want to open?" message. I confirm the open, but then I get a result of "no mountable file systems."

Does this mean I have a boot sector error and am out of luck?
Thanks!



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: samoir on Apr 23, '08 03:11:09PM

I found this hint to be extremely useful.

I used dd to successfully recover a failed 20GB ATA drive which had Windows XP as the filesystem. The drive wouldn't show after many attempts with the BIOS / Drive settings on the Windows PC. Using Apple's Disk Utility under Mac OS X 10.1 i could see the drive, but it wouldn't mount. I followed the hint above, as specified, using the default block-size as 512, and got 10GB throughput/per hour, which left me with a recovery.dmg after approx 2.25 hours (admittedly, and thankfully, a smaller drive).

For some reason the recovery.dmg wouldn't mount, (most likely something to do with me recently installing an old OS X 10.1 without applying any software updates) but copying this to my Mac Pro (OS X 10.5.2) the image mounted straight away, and i could backup the entire HDD, with huge success.

Thanks for an informative, and useful hint, that netted a great result using the command line. Cheers.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: RobK on May 28, '08 08:14:53AM
Don't use dd. Use the GNU ddrescue program which is designed to recover data from a faulty drive to a backup drive. dd is very primitive compared to ddrescue.

I realize that ddrescue was not around when this hint was submitted. But the GNU ddrescue program is the way to go.

In some of the previous posts, you will see a reference to dd_rescue. dd_rescue is a different program than GNU ddrescue. dd_rescue is older and absolete. GNU ddrescue has effectively replaced it and is much FASTER. Even the authors of dd_rescue recommend that you now use GNU ddrescue.

GNU ddrescue -- http://www.gnu.org/software/ddrescue/ddrescue.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: dilbert4life on Sep 09, '09 07:06:46AM

df -k will help and show you what you need, but only if the disk is actually mounted.

I prefer to use disktool, because it shows all disks that are attached to the computer, even if the partition is not mounted.

When I use dd, I connect and then unmount the disk, leaving it connected, just to ensure that the only I/O activity is the dd tool. Using
df -k, I was not able to see /dev/disk6s1, but using disktool -l, it showed just fine.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: derekd on Oct 22, '09 01:23:11AM

Wow, I love this tip!

So I've crated a dmg file using dd as described but now (excuse my ignorance) how do I write a bit for bit copy to a new hard drive?

Can I just use DiskUtility or Toast or do I need to do a reverse dd command in the terminal? If the later is the case, what would the command be? Do I just swap the input (if) and output(of) names?

Thanks for any help.




[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: pjx on Dec 01, '09 06:47:30PM

The command I give.

dd bs=512 if=/dev/disk1s1 of=/dev/disk1s3/volumes/ExpansionD/foo.dmg conv=noerror,sync

the reply I keep receiving.

dd: /dev/disk1s3/volumes/ExpansionD/foo.dmg: Not a directory

What am I doing wrong? I have tried many variations on the path to create the file with the same failure. Please help.


---
http://www.jbtvonline.com/gallery/wristm.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: pjx on Dec 01, '09 07:32:01PM

My Command was almost correct. I had to rewrite the of section. The dev and disk location don't belong there. The dev in the if section is copy the device. The of section is a guide to where. If you cannot cd there you cannot copy to there.

The corrected version that worked for me.

dd bs=512 if=/dev/disk1 of=/volumes/ExpansionD/foo2.dmg conv=noerror,sync

Just sharing how I got it working.

---
http://www.jbtvonline.com/gallery/wristm.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: pjx on Jan 25, '10 02:40:11PM

OK so I actually got the whole thing to work and create a volume. Now it is telling me that there is no mountable volume. Am I just done and there is nothing left that can be preformed?

---
http://www.jbtvonline.com/gallery/wristm.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: originalmacbabe on Jan 30, '10 09:27:21PM

I, too, and having trouble getting the drive attached. It was my boot disk, now it is invisible. It is spinning, but not seen. Cannot boot into single user or target mode, won't be seen as an external drive either.

You are all talking about drives that are visible to the system. Is it possible to make this happen or force attachment or mounting? If so, please tell someone who is not afraid of using terminal, but doesn't really know much about UNIX.

Techtools, DW, Mount Me, etc. all tried. It is as if the drive simply isn't there.

I could swap the board with an identical drive but someone suggested that if the drive is spinning, this won't help.

Is there any hope for me copying this drive?

Tx



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: mariapeter12 on Jun 08, '10 04:56:57AM

Sometimes even the dd Command fails to recover data from the dead Hard Drive at that time What should we do?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: oliver_chambers on Aug 17, '10 03:19:22PM

i have tried the command (dd bs=512 if=/dev/disk1s2 of=/volumes/untitled%2/foo.dmg conv=noerror,sync) on snow leopard 10.6.4 but all i get is "resource busy". Is my disk doomed? I only want the contents of two folders the downloads folder and the logic folder in the music folder. Is there any quick way into these?



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: oliver_chambers on Aug 17, '10 04:44:50PM

i now get having typed in dd bs=512 if=/dev/rdisk2 of=/volumes/spare/foo.dmg conv=noerror,sync
the result

dd: /dev/rdisk2: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 539.691029 secs (0 bytes/sec)
dd: /dev/rdisk2: Input/output error

someone help please!



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: aymantn on Jan 24, '11 01:50:56PM

More help about external hard drives :
http://harddriverestore.blogspot.com/2010/12/external-hard-drive-restore.html



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: andrej on Jul 06, '11 02:11:44AM

conv=noerror,sync is great, thanks!

next problem is that my drive contains NTFS partition and the bad block list was copied with data to new disk. Does anyone knows how to persuade NTFS partition that it does not contain any bad blocks? chkdsk c: /f /p does not work, it just add new bad blocks (if any) and never retest / remove existing.



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: andrej on Jul 07, '11 08:29:06AM

fixed using dfsee10x_stick.iso from http://www.dfsee.com/ even trial version is able to change NTFS's MFT records



[ Reply to This | # ]
Recover a dead hard drive using dd
Authored by: expertmac on Dec 26, '13 03:20:53AM

Very difficult to diagnose dead hard drive, if the OS has corrupted then you can access your data with help of another working pc and copy all data in another drive.

For more information: http://macintoshdatarecoverysoftware.blogspot.com

and

http://www.softwaredatarecovery.net/hard-drive-recovery.html



[ Reply to This | # ]
Sparce option to reduce img size
Authored by: grapesh on Dec 24, '12 08:26:33AM

Thanks, this is the best tool on restoring a busted drive! I thought I would also share one hint I discovered.

I ended up in a situation when I needed to restore an external USB harddrive, and I only had a spare harddrive of the same disk capacity (500M). So, making a disk image of the failed drive on a new drive crashed (after 2 days of dd-ing) with 'no disk space left on device' error. So, instead of running to get a larger-capacity USB drive, I figured out I can compress a new image with 'sparse' option, so it will fit on the available drive of the same size:

dd bs=512 if=/dev/rXX# of=/some_dir/foo.dmg conv=noerror,sync,sparse

'Sparse' basically skips NULL blocks (empty disk space), and the resulting foo.dmg is only of the size of data on a busted drive.



[ Reply to This | # ]
Sparce option to reduce img size
Authored by: grapesh on Dec 26, '12 08:23:15AM

Actually I have to take it back - On MacOSX 10.6.8, 'sparse' option for default dd does not reduce the destination image size.



[ Reply to This | # ]