Saturday, July 10, 2010

Speed up your disk cloning process

It's one thing to clone a hard disk, and quite another to actually wait for it to complete. ddrescue is a very powerful command but it's defaults leaves much to be desired. Since safety is a concern, there's nothing wrong with that.

But if you find that ddrescue is being far too conservative with the transfer bandwidth then there is a way to speed things up. ddrescue comes with a --block-size option that allows you to set higher transfer block sizes. It defaults to 512 bytes which means the large hard disk capacities of today can take quite a while to move across. Simply increasing input block size can have tremendous impact on the transfer speed.

~$ sudo ddrescue --block-size=4KiB -r3 /dev/sda /dev/sdb rescue.log

This deceptively simple addition to ddrescue means a massive increase in transfer speed, hence a huge time savings. Often it's a matter of experimentation to find the best setting to use for a particular disk. 4KiB should work well with today's disks without too much trouble.

--block-size accepts k, M, G, Ki, Mi, Gi  multipliers to minimise typing errors, where k = 10^3, Ki = 2^10, M = 10^6, Mi = 2^20, etc...

Setting a much higher block size doesn't necessarily mean an automatic increase in performance as it all boils down to the specific characteristics of the block device. With today's hard drives easily featuring 32MB or more in cache, you could gain even more performance by further increasing block size.

Related posts:

Command line hard disk cloning with gddrescue