Below are the steps that I followed to clone an RHEL5 guest running under vmware ESX-3.5 to Xen environment over the network. The method that I followed can be used to clone any virtual machine (except windows?) running under any virtualization product to any other virtualization product (Correct?). I agree that there are specific tools provided by vendors for p2v and v2v conversions, but they are limited to their virtualization product. Eg, Vmware tools may not be used to convert a virtual machine running under vmware to run on Xen/KVM and vice-versa.
Pre-requisites.
- Linux based LiveCD. (Which should have coreutils and nc - netcat - packages installed).
Below are the steps that I followed:
- Downloaded the LiveCD for Fedora 10 from here (You can use whatever Linux LiveCD you want.)
- Booted the rhel5 virtual machine already available in Vmware ESX from this ISO by attaching this ISO to the guest and selecting cdrom as the first boot device. (Consult the concerned documentation for more details)
- Created a new blank guest in Xen and assigned it a hard disk with the same size of vmware disk. I just created a fully virtualized guest using virt-manager and when it started the anaconda installation, aborted the installation and shutdown the guest. Now I have a guest with a blank image.
- Then started the blank guest under Xen from the Fedora LiveCD. (If not sure how to do it, please consult xen documentation).
Now we have both Vmware guest (will be called GuestA from now onwards) and a guest with blank image in Xen (will be called GuestB from now onwards) booted of the Fedora 10 Live CD.
- On both guests flush the iptables firewall.
# iptables -F
- Networking should be enabled automatically by the LiveCD. Make sure that networking is working as expected on both guests and they can ping each other.
- Run fdisk -l on both guests and identify how the hard disk has been detected. I had them detected as "/dev/sda" on both GuestA and GuestB.
- On GuestB, run the below command:
# nc -l 7000 | dd of=/dev/sda bs=16M
- On GuestA, run the below command.
# dd if=/dev/sda bs=16M | nc ip-of-GuestB 7000
Replace ip-of-GuestB with the actual ip of GuestB and replace /dev/sda with the actual block device in both commands. 7000 is the port number, you can use other unused ports as well.
The process of copying the hard disk image will take sometime depending upon the network bandwidth and the IO bandwidth availability of storage. Please be patient and restart GuestB once the process is over from the hard disk.
- Went to bed and had a good sleep. When I was up in the morning, I had the guest cloned successfully and started off the new guest.
3 comments:
I wonder if this would also work with Windows (via 2 Fedora live CDs) as long as the architecture stays the same.
It may not work for Windows guests!
The problem with windows is related to the storage controller drivers and the HAL. There are tricks that you can do such as removing all storage controllers from device manager prior to shutting down the windows machine but they're not fool proof.
There are some guides on the web but I can't seem to find them right now.
Post a Comment