A Slightly Better Way to Migrate Citrix Dedicated Catalogs to Another Datastore

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

  1. VMs would no longer be linked clones
  2. 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.

Process:

      1. Identify VDIs on each datastore inscope. (I use RVtools, or PowerCLI)
      2. Identify path to VMX file for each VDI. (I use RVtools, or PowerCLI)
      3. Add the new datastores to Citrix hosting group.
      4. Shutdown the VDI on the datastore in scope.
      5. Copy the contents of the entire datastore using PowerCLI
        Copy-DatastoreItem "vmstore:\DataCenterObject\DatastoreName01\*" "vmstore:\DataCenterObject\DatastoreName02\" -Force -Recurse
      6. remove orignal VMs from inventory using PowerCLI
        Remove-VM VMnameInVcenter confirm:$false
      7. Unmount original datastore from the ESXi hosts.
      8. 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
      9. 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
      10. 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
      11. Add the VDIs to vCenter inventory and power on using PowerCLI.
        New-VM -VMFilePath "[DatastoreName02] VMnameInVcenter/VMnameInVcenter.vmx" -vmhost anEsxiHostInVC
      12. Validate VDIs in citrix console.

Troubleshooting Note:
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

2 thoughts on “A Slightly Better Way to Migrate Citrix Dedicated Catalogs to Another Datastore”

  1. Rob – thanks for tip. Does it work with MCS with PVDISK? I try to move VM to another datastore (with different hosting unit name) and I think I’m stuck

    1. Yes this should work. The biggest problem with MCS is that it relies on multiple machines snapshots pointing to the same base disk. If you follow this process to move the vdi it will move the snapshot delta and fix the link to the base disk.

      -Rob

Leave a Reply

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