miercuri, 4 martie 2009

HowTO convert a XEN virtual machine to VMware

Here's my first HowTO, the first one of many other more to follow.

Steps assume advanced VMware and Xen knowledge.

Additional software requirements:

- qemu
- VMware Server 1.xx
- VMware Converter
- Knoppix LiveCD or the distro's first CD

Xen -> VMware VM migration steps (Kernel step)

The kernel on the VM to be migrated must support fully virtualized operation. The kernels used for para-virtulized machines using RHEL/Fedora/CentOS as a guest does not support fully virtualized operation by default. The best way to deal with this is to also install a standard kernel in the machine, port the machine and finally remove the Xen kernel.

1. Since this is a highly risky procedure, FIRST CREATE A BACK-UP OF YOUR VIRTUAL
2. Download a kernel with the same version number and architecture as the Xen kernel,
except it should be the a generic one. Use the distribution CD/DVD or any other
repository to get it.
3. Use RPM tools to install the kernel.
4. Modify /etc/modprobe.conf to add the proper SCSI and network card modules

alias eth0 xennet
alias scsi_hostadapter xenblk

will be replaced by

alias eth0 pcnet32
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix

This is an one way action. Once modified the kernel modules, you won't
be able to properly start the machine, and you will receive a Kernel
panic error message.

Xen -> VMware VM migration steps (Disk step)

To convert a XEN machine in a .vmdk format to be used with VMware, a tool called qemu will be used. QEMU is a generic and open source machine emulator and virtualizer. It is also a fast processor emulator using dynamic translation to achieve good emulation speed.

1. Download qemu from DAG repository. Use the EL5 package for any Fedora/RHEL5/CentOS5
that you use.
2. Convert the XEN machine to VMware:
qemu-img convert <> -O vmdk <>
3. At this point, we have a valid VMware Server 1.xx disk image. This can be
powered on onto any VMware Server. We need to do it anyway in order to build a .VMX
file that will be later used. This stage also confirms whether the newly machine runs

3.1 create a new virtual machine. Do not create a new HDD, but use the previously
created vmdk
3.2 power it on in order to validate that it is usable and to allow the machine to
reconfigure itself

4. Move the VMware Server virtual machine to a Windows workstation running VMware
5. Using VMware Converter, convert the VMware Server virtual machine to VMware ESXi

Xen -> VMware VM migration steps (ESX step)

1. configure the virtual machine to boot first from CD-rom drive
2. modify the machine's HDD SCSI controller type from BUS Logic to LSI Logic
Edit Virtual Machine Settings > SCSI Controller 0 > Change type > LSI Logic
3. Boot using Knoppix or the distribution's first CD
4. Mount the VM's disk and chroot to it
5. Get the disk architecture using fdisk -l, and modify /etc/fstab accordingly
6. Create a new initrd image. You also must know the version of the running kernel.
For example, if you are running kernel 2.6.18-1234, then the initrd command would
look like this:
# mkinitrd -v -f /boot/initrd-2.6.18-1234.img 2.6.18-1234
7. edit /boot/grub/menu.lst to boot from this initrd
8. keep your fingers crossed and reboot the machine

Don't forget to re-configure your network card

External references:


Un comentariu:

  1. Can a similar approach be used to convert a running Amazon AMI (virtual machine) instance to ESX 3.5? The people at VMWare tried helping me use Converter, but that didn't work since Amazon AMIs run Xen in the kernel.