A somewhat common issue that comes up with XenDesktop administrators is what to do when a datastore fills up, or is performing sub-optimally. From a vi admin the answer seems simple:
just do a storage vMotion
But what if the XenDesktop environment is using MCS(machine creation services)? In the VMware world this would be known as a linked clone. The issue that occurs if you do a svMotion, this will break the management from the Citrix console.
Citrix provides a KB article (CTX200434) that addresses this, but there are some issues with this method
- VMs would no longer be linked clones
- You lose some management functionality from the Citrix console, mainly disposing of the VDI
So to retain full MCS functionality, I put together a process to migrate the VDI. Be warned it is not fun, but it does work. I migrated around a thousand VDIs using this method.
- Identify VDIs on each datastore inscope. (I use RVtools, or PowerCLI)
- Identify path to VMX file for each VDI. (I use RVtools, or PowerCLI)
- Add the new datastores to Citrix hosting group.
- Shutdown the VDI on the datastore in scope.
- Copy the contents of the entire datastore using PowerCLI
Copy-DatastoreItem "vmstore:\DataCenterObject\DatastoreName01\*" "vmstore:\DataCenterObject\DatastoreName02\" -Force -Recurse
- remove orignal VMs from inventory using PowerCLI
Remove-VM VMnameInVcenter confirm:$false
- Unmount original datastore from the ESXi hosts.
- backup VMX file of VM on newdatastore using SSH to ESXi host
cp /vmfs/volumes/DatastoreName02/VMnameInVcenter/VMnameInVcenter.vmx /vmfs/volumes/DatastoreName02/VMnameInVcenter/VMnameInVcenter.vmx.bak
- Edit the VMX file, replacing the datastore UUID in the path to the virtual disks using SSH to ESXi host.
sed -i 's/DatastoreName01's UUID/DatastoreName02's UUID/g' /vmfs/volumes/DatastoreName02/VMnameInVcenter/VMnameInVcenter.vmx
- Edit the VMX file, adding the “I moved it” flag using SSH to ESXi host. If this step is skipped, the VDI wont’ boot up until you answer the prompt in vCenter. This can get very tedious if moving a bunch of VDIs, so I added this step.
echo 'answer.msg.uuid.altered="I moved it"' >> /vmfs/volumes/DatastoreName02/VMnameInVcenter/VMnameInVcenter.vmx
- Add the VDIs to vCenter inventory and power on using PowerCLI.
New-VM -VMFilePath "[DatastoreName02] VMnameInVcenter/VMnameInVcenter.vmx" -vmhost anEsxiHostInVC
- Validate VDIs in citrix console.
If the base disk image is NOT in the same datastore as the linked clone disk(s) you will also have to modify the vmdk file(s) of the linked clone. This is done using SSH to ESXi host.
sed -i 's/DatastoreName01's UUID/DatastoreName02's UUID/g' /vmfs/volumes/DatastoreName02/VMnameInVcenter/VmdkName-delta.vmdk