Is there a fast way I can clone a partition on to another drive using a sector by sector copy, instead of copying individual files?

apple.stackexchange https://apple.stackexchange.com/questions/286858

Question

I'm trying to transfer a 4 TB Time Machine backup from one USB 3 hard drive to another. I'm currently using SuperDuper to do it, and it's going to take upwards of two full days to perform the copy, if not longer.

That's significantly slower than the usual maximum speed for copying over USB 3, and I suspect that what's slowing things down is the overhead of copying each file individually, rather than just copying the raw data on the drive, sector by sector.

Given that I just need to duplicate a partition on to another drive:

  1. Would it result in a usable partition if I did a sector-by-sector copy?
  2. Would that be faster than using SuperDuper?
  3. And if yes to both of the above, what are some methods I could use to do that?

I already tried using Disk Utility's restore feature to clone feature, but it got about 5% of the way in and then failed with a weird error about a drive being busy. So I don't think it's reliable enough, and it has no option for resuming where it left off. But that said, it did seem like it was going much faster, and if it didn't fail, it would've taken around 8 hours for it to finish.

edit: for posterity, the reason Disk Utility failed to copy the drive is because my destination drive was dying and loaded with bad sectors. Under normal circumstances it would probably work and be about as fast as dd. However I like Allan's answer the most because, in case something causes dd to stop mid-copy, you can restart it from where it left off.

Was it helpful?

Solution

Use dd to clone your drive/partition.

The syntax is simple:

dd if=inputfile.foo of=outputfile.bar bs=blockSize

This will do a bit for bit copy of your drive. Whatever your drive "looks like", including partition tables, will be copied.

For example, assuming your Time Machine drive's identifier is /dev/disk3 and your second USB drive's identifier is /dev/disk4, your command would be:

dd if=/dev/disk3 of=/dev/disk4 bs=1M

You can also write directly to the raw device by using /dev/rdiskX

sudo dd if=/dev/rdisk3 of=/dev/rdisk4 bs=1M

Keep in mind, you will need to unmount the devices first with the command sudo diskutil unmountDisk diskX

Copy Speed

You are correct in assuming that there is some overhead associated with copying files. However, what you may not be aware of is that USB 3 speeds aren't what they are cracked up to be. USB 3 is upto 5Gbs (gigabits per second)... in a lab, on a clear day, with a really strong tail wind, going downhill.

The actual speed of USB 3.0 is closer to 100Mbps1

So, doing a little calculation, we find that to transfer a 4TB file at 100Mbps means it will take roughly 10 and a half hours at best (it could go slower!)

What I have found to be the most reliable for me is that I copy the file to an internal drive (or a network share as a 1Gbs wired connection is significantly faster than USB will ever be) and once I have the image, I then copy it to my target.

Breaking it up into two separate processes:

sudo dd if=/dev/rdisk3 of=/Volumes/Some/Network/Share/file.img bs=1M

sudo dd if=/Volumes/Some/Network/Share/file.img of=/dev/rdisk4  bs=1M

This has the added benefit that if anything happens, there is a copy in a safe place.


1 PC World: USB 3.0 speed: real and imagined

OTHER TIPS

In addition to Allan's answer, I should mention that using Disk Utility's restore feature does indeed seem to have similar performance to using dd. It's not so much that it's unreliable as the hard drive I was copying from is dying and has tons of bad sectors. dd failed on it too.

That said, dd allows you to resume a transfer part way through, so when cloning a drive I'm going to prefer that, even if it doesn't have nice UI like Apple tools.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top