I have a local machine that needs be migrated to remote disk. How can I do it with dd? I know local format for command
dd if=/dev/sdx of=/dev/sdx count=x bs=x
But how to do it via ssh direct from local to remote?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYou should run two instances of dd
in that case, one in the local host and the other one on the remote host (through ssh
.)
To make that work, you would omit the of=
argument, to have dd
write the blocks to stdout (which you can write to a pipe), or omit if=
to read from stdin (from a pipe.)
For example, copying from local to remote:
dd if=/dev/sdx bs=x count=x |
ssh user@host dd of=/dev/sdx bs=x
Or to copy from remote to local:
ssh user@host dd if=/dev/sdx bs=x count=x |
dd of=/dev/sdx bs=x
You likely want to use matching bs=
settings on both sides (though technically that's not strictly necessary.)