How to export a VPX instance on an SDX to an XVA file

How to export a VPX instance on an SDX to an XVA file

book

Article ID: CTX568511

calendar_today

Updated On:

Description

This article will describe how to export an XVA file of a VPX from an SDX.  This file contains the entire contents of the VPX including an image of the VPX's file systems.
 


Instructions

Method 1: Export to an external system with enough storage space, via ssh (SDX 13.x or newer only; does not work if target is FIPS)
 
On XenServer logged in as root:
xe vm-export vm=VMName filename= | ssh -T user@x.x.x.x 'cat > /pathOnExtSystem/filename.xva'
  • VMName is the name of the VM to export (you can use xe vm-list to find this if necessary)
  • user@x.x.x.x should be the username and IP of the device to scp the xva file to
  • /pathOnExtSystem/filename.xva is the file to place the exported XVA file on the device
 
The above command will take several minutes to complete, depending on the size of the resulting XVA file.  It will not show any progress, although you can check on the external device to watch the file as it is created
 
Method 2: Export to temporary VDI mounted to XenServer locally
 
NOTE: that you cannot export to the XenServer without a temporary VDI because there is not enough disk space on the Xen mounted partitions.
All steps below are on the XenServer, logged in as root.
 
Determine approximate size of the disk(s) that will be exported:
xe vm-list name-label=VMName params=uuid
uuid ( RO)    : 3043e1c2-82ac-9ecb-47c7-aaa41767b517

xe vbd-list vm-uuid=3043e1c2-82ac-9ecb-47c7-aaa41767b517 params=vdi-uuid
vdi-uuid ( RO)    : 5596d7cb-f2e7-43e8-81d1-802e1d2e0766
 
xe vdi-list uuid=5596d7cb-f2e7-43e8-81d1-802e1d2e0766 params=virtual-size
virtual-size ( RO)    : 21474836480
 
NOTE: There may be more than one VDI attached to the VM.  If so, add the virtual-size for each to get the approximate size of the resulting XVA file.
 
Determine which Storage Repository you want to create the temporary VDI on, which will hold the exported xva file:
pvscan
  PV /dev/sda4   VG VG_XenStorage-5c32bc7b-8725-0133-275b-578a5bc06fb5   lvm2 [220.46 GiB / 50.91 GiB free]
  Total: 1 [220.46 GiB] / in use: 1 [220.46 GiB] / in no VG: 0 [0   ]
 
NOTE: The UUID of the Storage repository that you wish to create the temporary space on; it should have sufficient free space for the XVA you estimated above.  The XVA file will be a little larger than the sum of the VDI size.
 
Create the VDI (virtual disk), specifying a size larger than the estimated XVA size:
xe vdi-create sr-uuid=5c32bc7b-8725-0133-275b-578a5bc06fb5 name-label=tempVDIName type=user virtual-size=25000000000
2fc0de94-c616-4731-859f-41a3905f8f8d
^^^ Note the UUID of the created VDI for later use below:
 
Create a vbd which associates the VDI with the XenServer Dom0
xe vm-list
uuid ( RO)           : 73a38c3b-b28e-4f64-8408-40990a79bdb6
     name-label ( RW): Control domain on host: netscaler-sdx
    power-state ( RO): running
^^^ Locate the uuid of XenServer Dom0.
 
xe vbd-create device=7 vm-uuid=73a38c3b-b28e-4f64-8408-40990a79bdb6 vdi-uuid=2fc0de94-c616-4731-859f-41a3905f8f8d bootable=false mode=RW type=Disk
7b99a08c-eb44-293c-cec9-bf0b595f9cc3
^^^ Note the UUID of the created VBD for later use below:
 
Note the pre-existing "td" device nodes
ls /dev/td*
/dev/tda  /dev/tdb  /dev/tdc  /dev/tdd  /dev/tde

Plug in (attach) the VBD/VDI to XenServer Dom0:
xe vbd-plug uuid=7b99a08c-eb44-293c-cec9-bf0b595f9cc3
Find the newly-created "td" device node
ls /dev/td*
/dev/tda  /dev/tdb  /dev/tdc  /dev/tdd  /dev/tde  /dev/tdf

Format and mount the VDI:
mkfs -t ext4 /dev/tdf

NOTE: If this is SDX 12.1, use ext3 instead.
 
mount /dev/tdf /mnt
^^^ This will make the temporary VDI appear as /mnt on the XenServer.  You can type df -h to confirm.
 

Export the VM as an XVA file to the temporary VDI

xe vm-export vm=VMName filename=/mnt/vm.xva
(If you get an error like CLIENT_ERROR, the vdi you created is not large enough to hold the XVA file; follow the cleanup steps below and then start over creating the VDI with a larger size.)
 
When this completes you can use an SCP client (ie winscp) to copy the resulting XVA file off of the XenServer.
 
Clean up steps (to delete temporary VDI):
umount /mnt
xe vbd-unplug uuid=7b99a08c-eb44-293c-cec9-bf0b595f9cc3
xe vbd-destroy uuid=7b99a08c-eb44-293c-cec9-bf0b595f9cc3
xe vdi-destroy uuid=2fc0de94-c616-4731-859f-41a3905f8f8d