The command dd
was modeled after the command DDR
(Disk Dump and Restore) from IBM mainframes from the 1960s and is mainly intended to convert and reblock block oriented I/O from/to block oriented disks. This is however not what you intend to do here.
The important problem in your use case is than you have an unreliable network pipe in the middle that does not grant to read specific block sizes.
If you are using a real dd
program (not sure what you use since your output is incompatible to the standard) you should get output like this:
"%u+%u records in\n", <number of whole input blocks>,
<number of partial input blocks>
"%u+%u records out\n", <number of whole output blocks>,
<number of partial output blocks>
You need to use dd
in a way that makes sure that you only get numbers > 0 before the plus sign and a 0 after the plus sign.
Since there is no grant to get a specific amount of data when reading from the ssh
output pipe, you need to make sure to always try to read less than you would get. You could still use the following command to read from the source disk:
dd if=/dev/xxx bs=16x1024k
without problems, but you need to use this command to read from the pipe and to write to the destination disk:
dd ibs=1b obs=16x1024k of=/dev/yyy
Do not user other options (in special none of the non-standard option you are using). If the dd
command that writes to the destination disk finally writes:
nnnn+0 records in
mmmm+0 records out
you have been successful and dd
did never read less than 512 bytes from the input and thus could correctly reblock the output.
If you see partial blocks (> 0 to the right of the plus sign) for the input blocks, you need to repeat the copy process.
Note that because of the large output blocksize, you of course may get one partial block written to the destination dist at the end. So the summary message for the dd
that writes to the destination disk may alternatively be:
nnnn+0 records in
mmmm+1 records out
conv=sync
from the right-hand dd and try the command line again. If that still gives you errors, please addiflag=fullblock
to the right-hand dd. – Mark Plotnick Jun 10 '20 at 04:07dd
, respectively) are a strong clue that, as Mark says, you neediflag=fullblock
. – q.undertow Jun 10 '20 at 04:28dd: bad argument: "iflag=fullblock"
so this is not related todd
. I added an answer that is based on a standarddd
implementation. – schily Jun 10 '20 at 07:32dd
is not a tool for cloning and will clone every single sector into the new disk even if it's unused. Use a proper cloning tool instead. They're smarter and much faster – phuclv Jun 10 '20 at 10:39ddrescue
and turn most network reliability issues into performance issues instead of letting them corrupt data. – Austin Hemmelgarn Jun 10 '20 at 13:40conv=
options withdd
is a mistake. – Mark Jun 11 '20 at 03:29iflag=fullblock
- you need it on both dd's – hanshenrik Jun 11 '20 at 15:21I want to try to recover the deleted files from the source disk, and I'm not sure whether DD is the only right tool for this situation.
- no it's not. use ddrescue for that. https://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html#Invoking-ddrescue – hanshenrik Jun 11 '20 at 15:23