Using dd to clone a HDD to an SSD?
I have a home machine running Windows 7, and I’m wondering if it would work to do a command like this:
dd if=/dev/${oldSataSpinningDisk} of=/dev/${newSSD}
To clone the contents of the current system running on a SATA HDD to a new SSD? mainly, would Windows 7 boot and actually work?
Just to add up to the (perfectly fine) existing answers:
Why do you need a blocksize bs=64
? While it is is probably not the fastest setting for all scenarios, it still runs way faster (around 4x) than the standard settings... this is true at least on my system - and seemingly many others out there. Tim Williscroft states that 100M could be faster, more research could be needed was done here, have a look.
Test data here: (I cancelled the first run because it took too long imho.)
$ sudo dd if=/dev/sdb4 of=/dev/sda2 status=progress
12962501120 bytes (13 GB, 12 GiB) copied, 394 s, 32,9 MB/s
$ sudo dd if=/dev/sdb4 of=/dev/sda2 status=progress bs=64K
13143113728 bytes (13 GB, 12 GiB) copied, 98,0026 s, 134 MB/s
More Hints and Ideas:
-
status=progress
is useful to monitor what happens, alternatives to that see this "Unix&Linux" post. I'd recommend addingconv=noerror,sync iflag=fullblock
for error safety -iflag
is unfortunately not POSIX required, but it is mentioned in the docs and needed in case you should use the wrong bs/ibs (this part was refined by Kamil Maciorowski - further reading). -
Also by Tim Williscroft: You could add the convention
conv=notrunc
. -
What you could also look into is a trick by Mistiry that
Nobody seems to know [...] dd is an asymmetrical copying program, meaning it will read first, then write, then back. You can pipe dd to itself and force it to perform the copy symmetrically, like this:
dd if=/dev/sda | dd of=/dev/sdb
. In my tests, running the command without the pipe gave me a throughput of ~112kb/s. With the pipe, I got ~235kb/s. I've never experienced any issues with this method. Good luck!
While he seems to misuse the the word symmetric in sense of meaning, this would probably also be worth a try.
Comment by groxxda: "If you do this and specify a blocksize, make sure you use the same blocksize on each invocation." (The respective post is also worth reading)
Yes, the idea is right, but the command is bad. If there is even one read error, the dd command will skip a byte which will cause the partitioning scheme to be faulty. You need to specify that every byte is copied to the same physical location (from the start).
dd if=/dev/oldsataspinningdisk of=/dev/newssd bs=64K conv=noerror,sync