Export a VM from Nutanix AHV to VMware ESXi

In this example I export a CentOS 7 template from AHV to ESXi.  There are a couple of ways to accomplish this task, depending on whether you need a thin provisioned file or a thick provisioned file.

Thin Provisioned

Step 1: Find UUID of the vDisk.

Connect to a CVM, enter aCLI and run the command vm.get [vm name]

Copy the vmdisk_uuid.  (Notice the size of the VM under the STORAGE column in PRISM, that should be the size of the exported file… assuming the VM only has 1 vdisk)

clip_image001

clip_image002

 

Step 2: Export the vDisk

vDisks of AHV VMs are located in a hidden folder on the container named .acropolis.  We use the qemu-img command to export the vDisk.  The vdisk is exported in a thin format and should match the size of the VM in PRISM.  If the disk is large then the command might take longer to complete than the timeout value of the SSH session.  In order to not have the conversion corrupted by the SSH session timing out either use keep alives or run the task in the background by using a ‘&’ at the end of the command.  In this example I will run the task in the background.

Make sure the VM is powered off, then run the following command:

qemu-img convert –O vmdk nfs://127.0.0.1/[container]/.acropolis/vmdisk/[UUID] nfs://127.0.0.1/[container]/[vmdisk].vmdk &

Example:
qemu-img convert -O vmdk nfs://127.0.0.1/Nutanix/.acropolis/vmdisk/fea6b382-43ec-4236-b521-edac7ac923cb nfs://127.0.0.1/Nutanix/CentOS_7.vmdk &

We can check that the task is still running using the command PS –A | grep qemu.  When the command returns nothing we know it has completed.

clip_image003

 

Step 3: Copy the vDisk

Once the export completes, you can now whitelist a Windows 2012 R2 server and simply browse to the container and copy the vDisk.  Alternatively you can also use a SCP tool  by connecting with admin@[host]:2222.

clip_image004

clip_image005

 

Step 4.  Create a new Virtual Machine and Upload the VMDK to ESXi.

Here I create a new VM with no virtual disk, because I am going to upload the VMDK to the VM’s folder.
clip_image006

Use a SCP tool to connect to ESXi and upload the VMDK to the VM’s folder.

clip_image007

 

Step 5: Use vmkfstools to create the vmdk disk descriptor.

ESXi expects vmdks to have a disk descriptor file that points to the raw vmdk file.  We can use vmkfstools to create that using the following command:

vmkfstools –i [sourceVMDK] [destinationVMDK] –d thin
Example:
vmkfstools –i CentOS_7.vmdk CentOS7.vmdk –d thin
Once the disk descriptor is created you can delete the original file.
clip_image008

 

Step 6: Attach the VMDK to the VM and power it on

clip_image009

clip_image010

 

Thick Provisioned

Exporting a thick provisioned disk is similar to the process above, except we don’t need to use qemu.  We can just SCP the disk from the .acropolis directory.

Step 1: Find UUID of the vDisk.

Connect to a CVM, enter aCLI and run the command vm.get [vm name]

Copy the vmdisk_uuid.  (Notice the size of the VM under the STORAGE column in PRISM, that should be the size of the exported file… assuming the VM only has 1 vdisk)

clip_image011

clip_image012

 

Step 2: SCP the vdisk from the .acropolis/vmdisk directory.

Use a SCP tool to connect to the Nutanix CVM.  If you use WINSCP you will have to use the Open Directory button (CTRL+O) to open the hidden .acropolis/vmdisk directory.

clip_image013

clip_image014

Copy the vDisk that matches the UUID from vm.get. Then copy the file to ESXi.
clip_image015

 

Step 3.  Create a new Virtual Machine and Upload the VMDK to ESXi.

Here I create a new VM with no virtual disk, because I am going to upload the VMDK to the VM’s folder.
clip_image016

Use a SCP tool to connect to ESXi and upload the VMDK to the VM’s folder.

clip_image017

 

Step 4: Use vmkfstools to create a VMDK descriptor file, then replace the flat file with the exported vDisk.

Following the process in VMware KB 1002511 we recreate a vDisk descriptor file.  The file has to be created with the exact same size as the exported vDisk.  Use ls –l to check the size of the exported vDisk.  Then use the following command to create the vDisk descriptor file:
vmkfstools –c [vDisk size] [destination file] –d thin

Example:
vmkfstools -c 42949672960 CentOS_7.vmdk -d thin

Once the file is created then replace the –flat.vmdk file with the exported vDisk.
Example:
mv fea6b382-43ec-4236-b521-edac7ac923cb CentOS_7-flat.vmdk

clip_image018

 

Step 5: Attach the VMDK to the VM and power it on

clip_image019

clip_image020

Leave a Reply

Your email address will not be published. Required fields are marked *