37 Comments
- colinm, on 10/12/2007, -1/+34I use dd to do all my backups. Here's some additional useful options (examples are for the whole of the first IDE drive - /dev/hda, and simplified, e.g. leaving out conv=sync,noerror etc to make it clearer):
Backup MBR (boot code + partition table):
dd if=/dev/hda of=mbr count=1 bs=512
Restore boot code + partition table:
dd if=mbr of=/dev/hda
Restore, not including partition table:
dd of=/dev/hda if=mbr bs=448 count=1
Saving partition sizes to text file:
fdisk -l /dev/hda >partition-info.txt
Backing up to gzipped file:
dd if=/dev/hda | gzip >hda.gz
Restoring:
gunzip -c hda.gz | dd of=/dev/hda
Backing up to archive split into 1GB chunks:
dd if=/dev/hda | split -b 1024m -d - hda.
Restoring:
cat hda.* | dd of=/dev/hda
Backing up over ssh tunnel to remote machine (blowfish = faster):
dd if=/dev/hda | ssh -c blowfish user@machine "dd of=hda"
copying files over ssh tunnel:
tar cv /source | ssh -c blowfish user@machine "cd /destination ; tar x"
It's possible to combine these with pipes - e.g. gzipping before sending over ssh and then splitting into chunks... You can change the order to optimise for network bandwidth, CPU of source / destination machine etc. - cdawzrd, on 10/12/2007, -5/+33Nice article, good instructions, but did they really have to add on the "Windows sux, OSX rulez forever!1!" at the end? It kind of turned me off to the author(s) even if the advice they give is true and good.
- nwily, on 10/12/2007, -1/+23dd isn't just a disk copying utility. It is a "Convert and Copy" utility. They were originally going to call it "cc" but that is the name of the C Compiler on most systems, so they incremented the letters, and voila, dd.
- edzieba, on 10/12/2007, -2/+20Especially seeing as there's dd for windows.
http://uranus.it.swin.edu.au/~jn/linux/rawwrite/dd.htm - piratebill, on 10/12/2007, -0/+18Just dont do it the way this guy did :)
http://www.hardforum.com/showthread.php?p=1028112728 - sn00kie, on 10/12/2007, -0/+13One thing the article didn't mention was that if the hard drive is not recognized by the bios at boot, then the operating system wont see it. You'll then have to fall back to alternative methods and send it to a hard drive recovery company.
Ex:
No bios recognition, no /dev/hdx....
Otherwise, great work. - julielacombe, on 10/12/2007, -3/+14And if it's mechanically dead, Freeze it ;)
http://geeksaresexy.blogspot.com/2006/01/freeze-your-hard-drive-to-recover-data.html - 0004, on 07/04/2008, -0/+10if it's mechanically dead and the read/write heads (those one-millimeter sized bits at the end) have detached themselves from their supports you can use the HDD as an ASH TRAY :P
there's nothing in the world that can recover such a trashed HDD... keep in mind that the dislodged heads might have scratched the surface of the platter.
You *MIGHT* recover some of the data in a specialized lab, but that costs at least 5..10 thousand US dollars to do.... which might not be justified to spend on. - burke, on 10/12/2007, -0/+10holy crap, why did this guy get modded down? That is the best information I've seen today! I had no idea Blowfish was faster than the default.
- XTrek, on 10/12/2007, -0/+9You can also get dd on your win box by downloading cygwin.
- dicerandom, on 10/12/2007, -0/+9From TFA: In straight UNIX, if you try to mount a disk image, it complains that there is "no block device" and fails.
This is why we have loopback devices.
mount -o loop hdd.img /mnt/whatever
Syntax may be different with BSD-ish core utils vs. GNU-ish utils. - cdawzrd, on 10/12/2007, -1/+8Reading the meaning behind "Once again, that which destroys a Windows box becomes a play thing to a Mac OS X box." The [reply] button is another thing you must have read over.
- aaaaa, on 10/12/2007, -0/+7Check out dd_rescue too. Useful when your drive is just dying and you need to copy the good sectors first.
http://www.garloff.de/kurt/linux/ddrescue/ - HeavyMetaler, on 10/12/2007, -0/+3That's why you gzip it....nothing compresses better then....well... nothing.
- ddales, on 10/12/2007, -0/+2Also handy for making backups of your software. (dd if=/cdordvddevice of=/directory/softwaretitle.iso) Of course it won't stip copyright protection or product keys but you will have an exact digital image of your original
Extremely time saving when working with VMware Server. Make an ISO, create a new VM, add a CD/DVD drive, tell it to use the ISO rather than a physical device, install from disk instead of waiting for the CD/DVD drive. - molecule, on 10/12/2007, -0/+2good article on a good utility, but i'll make the obvious greybeard comment:
"straight UNIX"? wtf is that? every UNIX is bent in its own way, including GNU/Linux and the BSDs. - Benad, on 10/12/2007, -0/+2Great to create disk images, but useless to restore a disk if the file system blocks are corrupted, i.e. reading them returns garbage every time you read the blocks.
That's why we're going toward ZFS at work, since every block pointer has a checksum of the block it points to, and combined with RAID-Z or a disk mirror recovery is automatic and transparent.
http://en.wikipedia.org/wiki/ZFS - tagawa, on 10/12/2007, -0/+1Can this be used in similar situations to SpinRite, HDD Regenerator, etc. or have I overlooked something?
- pct85, on 10/12/2007, -0/+1This article is a great start, but being mac OSX focused, it misses some other great hints. Imaging a broken hard drive can be even more successful under Linux.
The key is coming to an understanding of what kind of failure your drive has suffered. I have occasionally found a drive is broken only because the DMA capabilities of the drive have failed. Turning DMA off and downgrading other performance characteristics of a drive will often lead to greater, if not 100% recovery of the image. The "hdparam" command on most linux systems to turn of advanced features will give far more control and can be used before the dd command. The image may take longer, but the results are often far better. - inactive, on 10/12/2007, -0/+1I was hoping this trick would let me recover my files from a pair of dead maxtor drives, but dd is returning "device not configured" =(
I had these two maxtor 80gb's in a raid 1 setup thinking I was safe but they both cratered within about an hour of each other. pwnd. - dbr_onix, on 10/12/2007, -0/+1Hm, very similar to http://geektechnique.org/blog/703/dying-ibook-drive which I read a few days ago (The blog is nothing to do with me, I just like reading it), but has other links to stuff like replacing a powerbook's harddrive, and acctually using the data again once you've dd'd it back to a new drive
- Ben - fanboydcs, on 10/12/2007, -0/+1No hfs has no size limits.. well im sure over 1tb it might have issues..
- acidxwarp, on 10/12/2007, -1/+1One of the drawbacks of using dd on FAT/NTFS over ghost is that you need to dd an entire drive, whereas norton ghost would just image the data portions. If you have a 300gb drive and only 100gb of data, you're gonna get a 300gb image with dd and only a 100gb image with ghost.
On the other hand it is possible to only dd the first N number of gigs on an NTFS drive/partition but this would only work well if you just happened to do a recent defrag. And you probably dont want to risk running one now on a dying drive ;) - colinm, on 10/12/2007, -0/+0cat hda.* | dd of=/dev/hda
...as I said above ;-) - djtansey, on 10/12/2007, -0/+0Does mac os X not have file size limits? The first time I did this on linux, it stopped when I had created a 4gb file. Then I made a fix like the one posted above (dd if=/dev/hda | split -b 1024m -d - hda.)
But that was just for backup. How would you recover data from an image that has been split up with tons of 1024m files? - naxx, on 10/12/2007, -1/+0The article mentions the output file extension as "dmg." On Linux, what extension would I choose (e.g. a partition that I can browse through)?
- burke, on 10/12/2007, -2/+1SCO? No idea.
- compu73rg33k, on 10/12/2007, -4/+2Cool, congratulations.
- jcraig949, on 10/12/2007, -9/+7maybe we should change the words to reflect the acronym... donvert and dopy?
- binkyhuckaback, on 10/12/2007, -7/+2> did they really have to add on the "Windows sux, OSX rulez forever!1!"
> at the end?
Where did you get that from? It's not in the article I read. - burke, on 10/12/2007, -10/+3Cool. I need to learn more about dd.
- DanielNielsen, on 10/12/2007, -10/+3Awsome article
- Jnetty99, on 10/12/2007, -8/+1What if the need seems to be moving inside? Then you are screwed unless you pay for expert recovery.
- inactive, on 10/12/2007, -22/+2check here one more http://www.digg.com/linux_unix/Backup_entire_hard_disk_and_MBR_using_dd_command


What is Digg?