Virtualization – Turning a Running Linux System into a KVM Instance on Another Machine

kvm-virtualizationmigrationphysical-to-virtualvirtualization

I have two physical machines that I wish to virtualize.

I can not (physically) plug the hard drives from either machine into the new machine that will act as their VM host, so I think that copying the entire structure of the system over using dd is out of the question.

How can I best go about migrating these machines from their hardware to the KVM environment? I've set up empty, unformatted LVM logical volumes to host their filesystems, with the understanding that giving the VMs a real partition to work with achieves higher performance than sticking an image on the filesystem.

Would I be better off creating new OS installs and rsyncing the differences over?

FWIW, the two machines to be VM'd are running CentOS 5, and the host machine is running Ubuntu Server 10.04 for no particularly important reason. I doubt this matters too much, as it's still going to be KVM and libvert that matter.

Best Answer

You could possibly pipe the output from dd through an SSH tunnel to your target machine. I've known it to be done relatively successfully into a VMWare virtual machine.

Good details in the main answer here, and provides instructions for what to do if SSH isn't running (a number of liveCDs have SSH server on them anyway, so shouldn't be a problem): How to set up disk cloning with dd, netcat and ssh tunnel?