Loading
Home ›
Tech Tip: Remote Mirroring Using nc and dd
Aug 06, 2009 By Arun Maurya
in
You can use the dd and nc commands for exact disk mirroring from one server to another. The following commands send data from Server1 to Server2:
Server2# nc -l 12345 | dd of=/dev/sdb
Server1# dd if=/dev/sda | nc server2 12345
Make sure that you issue Server2's command first so that it's listening on port 12345 when Server1 starts sending its data.
Unless you're sure that the disk is not being modified, it's better to boot Server1 from a RescueCD or LiveCD to do the copy.
______________________
################################# # Arun Maurya (अरुण मौर्य) # #################################
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- This is a great program. We
1 hour 48 min ago - No Air for Linux
3 hours 38 min ago - HEWLETT PACKARD created
3 hours 48 min ago - HEWLETT PACKARD created
3 hours 50 min ago - very helpful :)
4 hours 12 min ago - I'll give it a whirl
12 hours 46 min ago - TFPT, don't you mean TFTP!? I
21 hours 14 min ago - wunderbar!!
21 hours 33 min ago - Lubuntu on a USB key
1 day 11 hours ago - Because XFCE is neither fish
2 days 2 hours ago





Comments
RSYNC!
Rsync doesnt do a block by block copy, hence it is not a valid solution for imaging an entire hdd.
*Rsync simply copies files and not drive structure partitions etc.
*Rsync is great for backing up data but if you want a complete copy of a drive its gotta be dd as it can copy everything.
RSYNC
I would still prefer rsync
Very nice, short and sweet.
Very nice, short and sweet. The comment trail is invaluable.
Tip means tip
Netcat, also called "The TCP/IP Swiss Army Knife" is a utility that is able to write and read data across TCP and UDP network connections...and more you can read in man nc ..
Use rsync!
rsync does it all, including updating your mirror for incremental changes without recopying the whole thing.
nc vs. ssh
nc is short for netcat (and in some distributions it -- whatever variant of netcat "it" refers to -- has that name). nmap now brings ncat, too, which has basically the same property (and a lot more): It connects the stdin/-out w/ a TCP socket (or UDP in some versions). So it streams data back and forth through an TCP stream, allowing for "piping via the net".
Well, and then we have ssh. It's (arguably) easier to handle, and provides cryptography, something you might want, rather than streaming your precious data unencrypted:
on the client/source side of things:
dd if=/dev/blah | ssh user@server dd of=/dev/target(and nothing on the server/target, so no port open for an attacker that wants to write to your block device, either.)
Hint for dd
Also, sending a USR1 to the dd process will show the amount of data transferred without killing the process itself.
Great; a stub that doesn't
Great; a stub that doesn't explain anything at all. How about educating users about what netcat and dd actually do, and the security implications of sending your hard drive contents bit-by-bit over a network? This looks like it was written in about 1 minute or less.
I used to tar files and
I used to tar files and stream them over net with the same commands (dd <-> tar). This helps to minimise traffic.
Compress the stream with
Compress the stream with gzip. It would speed up things a bit.
Server2# nc -l 12345 | gzip -dc | dd of=/dev/sdb
Server1# dd if=/dev/sda | gzip | nc server2 12345
Don't be lazy. It's at your
Don't be lazy. It's at your fingertips if you just man nc or even google it.
nc is netcat, a simple unix utility for reading and writing data across network connections. Instead of piping to STDIN, STDOUT or a file, you're piping the data stream to a network socket.
Can you please provide more
Can you please provide more info about what these commands are actually doing? I've used dd before, but nc is completely new to me. Talk about a stub.