Copy disk images for Vmware, KVM, etc.

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

These instructions can be used to copy full disk images over a network, including from or to physical and/or virtual machines. Because it is a bit-by-bit copy of the disk the process is independent of the file system or partition type, but there must be sufficient space on the destination disk. Individual partitions can also be copied by specifying the partition numbers in place of the disk reference (eg. /dev/sda1). All data is copied, including empty space, so this may not be the most efficient method to copy a sparsely filled drive.

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.