[olug] Cheap ghost alternative...

Dan Linder dan at linder.org
Wed Jun 2 13:53:37 UTC 2010


Over the weekend I needed to copy the partitions of one virtual machine to
another over the network (moving HDDs wasn't an option).  For some reason I
couldn't quickly find a free tool to do this (I thought the gparted tools
use to do this...) but I found a page showing how to use NetCat and DD:

Source machine:
  dd if=/dev/sda | nc $DEST_IP $DEST_PORT -q10

Destination Machine @ DEST_IP
  nc -l $DEST_PORT | dd of=/dev/sda

I was getting ~8MB/sec on in-home lan switch.

To make the transfer more visible and see the speed in real-time, use the
"pv" program - Pipe View.  It goes in-line between the nc and dd commands to
show speed of data with output like this:
    1.61GB 0:08:11 [7.63MB/s] [      <=>                                ]

Place "| pv" between the nc and dd commands like this:
  dd if=/dev/sda | pv | nc $DEST_IP $DEST_PORT -q10

I didn't try this, but they also suggested to use "gzip" between nc and dd
to compress network bandwidth:
 - source: dd .... | gzip  -cf | nc ...
 - destination: nc ... | gzip -dfc | dd ...

Combining them all together:
  dd if=/dev/sda | pv | gzip -cf | nc $DEST_IP $DEST_PORT -q10
Should show the rate of the raw data being sent across the network.

Hope someone else finds this useful.

DanL

P.S. I booted from a Ubuntu ISO 10.04 image which has dd, nc, and gzip by
default - I had to install pv using apt-get IIRC.

-- 
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
   (Who can watch the watchmen?)
   -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
   -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************



More information about the OLUG mailing list