How to create a virtual machine from a live server

backupremotevirtual machine

I am looking for ways to remotely clone a live server into a virtual machine, in order to use it as a test environment that is as identical as possible to the live server. This would be used to test changes, new software versions, etc. The clone would need to contain the boot manager, partition info, etc.

What are ways I could accomplish this with a minimum of impact on the live server, while producing a working image that I can boot from (assuming it is mounted in the proper way or converted to an image after the clone)?

The live server runs Centos 6.7, and I'm planning to use Virtualbox to run the clone. I am doing this from a Mac with Homebrew, bonus points if the answer will work from a Mac but can use *nix if needed.

I've tried using rsync and creating an image from the resulting folder, but it was missing partition & boot info so I couldn't use the resulting image in Virtualbox without first installing centos then copying over all the files – I felt this wouldn't be faithful enough for a test environment.

Update: I've tried using the VMware converter but unfortunately it only seems available for windows and I'm not able to use it.

Instead, I'm downloading an image of the server by using dd over ssh. I plan to convert this image once it's downloaded into a .vdi using virtuablox's command line utility. If this works I'll update the question with more details.

Best Answer

Physical to virtual - P2V - is the procedure you are looking for. rsync will not help in this case.

You should use a Vmware's free VMware Converter tool to convert the disks of your physical server to virtual disks, create a virtual machine in VirtualBox and add the existing virtual disks to it.
You'll find a complete step-by-step description here.

Related Question