Wednesday, January 4, 2012

Copy disk images for Vmware, KVM, etc.

(Ref: Elvis, http://forums.overclockers.com.au/showthread.php?t=933797)

Boot both machines with a LiveCD (e.g. PartedMagic).
SSH from source into destination machine, to get the key, then exit.
On the source machine execute the following command:

dd if=/dev/sda bs=4096 conv=noerror,notrunc | bzip2 | ssh root@otherserver "cat | bunzip2 > /dev/sdx"

where:
/dev/sdx is the destination disk.
bzip2 can be removed for fast (local) copies.
"noerror" is added to allow the copy to continue on read errors, e.g. in cases of recovering corrupt systems to virtual machines.
"notrunc" maintains data integrity by not truncating data.

No comments:

Post a Comment