Skip to main content

Migrating a Linux KVM machine to VMWare ESX

There are several steps to move your linux kvm virtual machine to an VMWare ESX cluster.

The first step after shutting down the kvm instance is to convert its disk format to vmdk format. qemu-img tool makes this step easy.
On the kvm host:
# qemu-img convert -O vmdk kvm-image.img esx-image.vmdk -p

Now the vmdk file must be uploaded to esx host. In order to scp to esx host, sshd daemon must be started.
On esx host:
# service sshd restart
On kvm host:
# scp esx-image.vmdk user@esx-host:/path/to/datastore

It is time to create the esx virtual machine by using the vmdk file:
Using vSphere Client, right click on the desired host and select New Virtual Machine. In the Create New Virtual Machine wizard, select custom configuration. Provide detailed options in the later screens that suits you best. Then later in the Create a Disk screen, select Use an Existing Virtual Disk. Click Browse and navigate to the location of your existing vmdk file. Review the summary then finish.

After running newly created esx virtual machine, it is possible to encounter errors when starting or creating snapshots.
2016-08-18T06:12:50.598Z| vcpu-0| I120: DISKLIB-CHAINESX : ChainESXOpenSubChainNode: can't create multiextent node 7eea123d-esx-image-00001-s001.vmdk failed with error The system cannot find the file specified (0xbad0003, Not found)
2016-08-18T06:12:50.599Z| vcpu-0| I120: DISKLIB-CHAIN : "/vmfs/volumes/54525cc9-bd43329e8-3a47-b2ba3eef754a/esx-image/esx-image-00001.vmdk" : failed to open (The system cannot find the file specified).

That is because your virtual machine disks are of a hosted type. To resolve this issue you should convert virtual disks in hosted format to one of the vmfs formats. Hosted disks end with the -s00x.vmdk extension.

Open a ssh console to the ESXi host. Run this command to load the multiextent module:
# vmkload_mod multiextent
To convert virtual disks in hosted format to the VMFS format:
For a thick disk:
# vmkfstools -i esx-image.vmdk esx-image-new.vmdk -d zeroedthick
Or for a thin disk:
# vmkfstools -i esx-image.vmdk esx-image-new.vmdk -d thin
If conversion successful, Delete the hosted disk:
# vmkfstools -U esx-image.vmdk
Rename the new VMFS disk to the original name:
# vmkfstools -E esx-image-new.vmdk esx-image.vmdk
Unload the multiextent module:
# vmkload_mod -u multiextent


Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.