I had occasion to clone a hard-disk over the network today. I wanted to replicate a VM setup that I already had running in one machine, over onto another, which will save me time from setting it up again. So, I checked the internet about using dd with nc to clone over the network. Most places gave the following info:
Target:
# nc -l -p 9000 | dd of=/dev/sda2
Source:
# dd if=/dev/sda2 | nc serverip 9000
However, trying that set of commands would fail. So, checking the man pages for NetCat revealed that you cannot use both the -l and -p parameters together. So, the correct set of commands should be as follows:
Target:
# nc -l 9000 | dd of=/dev/sda2
Source:
# dd if=/dev/sda2 | nc serverip 9000
Which worked out just fine in the end. Thought I’d share it.