Tag Archives: ESXi

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

Export a VM from AHV raw format to VMware VMDK

In this example I’m going to export my Windows 2012 R2 template from AHV to ESXi.

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)

image

image

 

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.

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/838950be-d0d8-4132-bf8f-e02411807cf2 nfs://127.0.0.1/Nutanix/win2012r2.vmdk

 

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 and import it into ESXi.  Alternatively you could just mount the container as NFS on the ESXi host and storage vMotion it to another datastore.

image

 

Step 4.  Create a VM with the new vdisk and power it on.  Remember to install VMware Tools.

image

Upgrade Nutanix 1350 block to ESXi 5.5

Nutanix recommends that you upgrade to vSphere 5.5 using the VMware Update manager instead of directly mounting the ISO.

Another way to upgrade instead of installing Update Manager is to just download the offline bundle and run the command:

esxcli software vib update –d “FILEPATH to OFFLINE BUNDLE”

Here are the steps that I used to upgrade my nodes from ESXi 5.0.0 to ESXi 5.5.

  1. Download ESXi 5.5 bundle from VMware.
  2. Upload the bundle to the root of my Nutanix datastore

    image

  3. SSH to the CVM.  From the CVM we can execute a script that will run on all of the hosts:

    for i in hostips; do echo $i && ssh root@$i "esxcli software vib install -d /FILEPATH TO OFFLINE BUNDLE"; done

    *I missed that the hostips is encapsulated with backticks and not ‘’ single quotes so I just logged onto each host and ran “esxcli software vib install –d /FILEPATH TO OFFLINE BUNDLE”

    image

  4. Shutdown the CVM.  We are able to shut down one CVM at a time without disrupting the state of the cluster.   Then reboot the host.

     image

  5. Rut-roh!  My host didn’t come back into vCenter.  When I try to force it to reconnect it tells me that some virtual machines powered back on without following the cluster EVC rules.  Upgrading to ESXi 5.5 must have reset the EVC setting on that host.

    image

    To remedy it I shut down the CVM, force the host to reconnect, then power the CVM back on.  On the next node I just put the host into maintenance mode before I reboot.

Copy files between ESXi hosts using SCP

Need a quick way to move files on one datastore to the datastore of another host that is not within the same vCenter?

In a Nutanix environment SSH is enabled on the hosts so we can use SCP to do this.  I needed to move an ISO repository from the production cluster to the TEST / DEV cluster.  Log into the source host as root, change directory to the datastore folder  (/vmfs/volumes/DATASTORE/FOLDER) and then run the following command:

scp –r * root@DESTINATION:/vmfs/volumes/DATASTORE/FOLDER

# The destination FOLDER must already exist on the destination DATASTORE.