4

In :

sudo dd if=/dev/sda bs=64k | pv --size 1.5t | dd of=/dev/sdb

Does the block size for dd go on the left side of this after the input as shown or on the right after the output?

With the pipe viewer size option, is it correct that there is no equals sign before the value? Is it okay to use a decimal value as shown above?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
Less Static
  • 61
  • 1
  • 5

1 Answers1

9

A number of issues that might benefit from review.

sudo dd if=/dev/sda bs=64k | pv --size 1.5t | dd of=/dev/sdb

Firstly, you can (vastly) increase the block size and correspondingly increase the throughput. I often use bs=32M. The order of the parameters to dd does not matter, so:

sudo dd if=/dev/sda bs=1M

Next, it doesn't matter whether you specify --size with or without an equals. Long args (those starting with a double dash) usually aren't fussy. However, a quick try out of pv shows that the argument must be an integer. So:

pv --size 1500g

Finally, it would be worth specifying a large (output) buffer for dd, and you'll probably need to run it with root privileges. Because we are using a large buffer it's worth ensuring we have filled it completely before trying to write it out. So you end up with this:

sudo dd of=/dev/sdb bs=1M iflag=fullblock

Putting it all together,

sudo dd if=/dev/sda bs=1M | pv --size 1500g | sudo dd of=/dev/sdb bs=1M iflag=fullblock

I should really point out, though, that on Linux-based systems there's no need to use dd for copying from/to disk drives. On this basis the whole command chain can be simplified to just this,

sudo sh -c 'pv --skip-errors --size 1500g </dev/sda >/dev/sdb'
roaima
  • 107,089
  • 14
  • 139
  • 261
  • 1
    @sudodus that's nothing to do with the question as asked. However there are a number of solutions here that address sync/flush times – roaima Jun 04 '22 at 13:52
  • 1
    Thanks, I found and tested `blockdev --flushbufs /dev/sdx` to flush a single device – sudodus Jun 04 '22 at 16:09