Tag Archives: AHV

Export an ISO from the Image Service on Nutanix AHV

Nutanix AHV has an image service built into PRISM that lets you upload ISO files and connect them to VMs.  Currently there is no export for the image service built into PRISM. 

image

However, it is not hard to export this ISO if you need to.

Step 1: Find the vmdisk_uuid for the Image

Log into a CVM and go into acli.

List the images using: image.list

Get the details for the image using image.get [Image Name]. 
Example: image.get Windows10

Note the vmdisk_uuid.

image

 

Step 2: Use a SCP tool to copy the vmDisk

Use a SCP tool like WinSCP to log into the CVM.  You need to log in with a PRISM user/pass to port 2222.  In this example I use the default login “admin”.

image

 

The .acropolis folder is hidden so use the open folder button to browse to the .acropolis/vmdisk folder.

image

 

Right click on the UUID and select download.

Screen Shot 2017-02-16 at 10.30.00 AM

 

Type in a name for the iso.  In this example I name it Windows10.iso

image

image

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

Export a VM on AHV

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.

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.  One cool thing is that the vDisk is exported in a thin format, so even if it is provisioned as a 100GB drive, it will only export the actual size used.

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

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

Example:
qemu-img convert -c nfs://127.0.0.1/Nutanix/.acropolis/vmdisk/5c0996b9-f114-475f-98c0-ea4d09e8e447 -O qcow2 nfs://127.0.0.1/Nutanix/export_me.qcow2

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.

image