Friday, January 25, 2013

Xen - Moving Virtual Disk Images (VDIs) between SRs

Copying all of a VM's VDIs to a different SR

The XenCenter Copy VM function will create copies of all VDIs for a selected VM on the same or a different SR. The source VM and VDIs are not affected by default. To move the VM to the selected SR rather than creating a copy, select the "Remove original VM" option in the Copy Virtual Machine dialog box.
  1. Shutdown the VM.
  2. Within XenCenter select the VM and then select the VM ... Copy VM menu option.
  3. Select the desired target SR.

Copying individual VDIs to a different SR

A combination of the xe CLI and XenCenter can be used to copy individual VDIs between SRs.
  1. Shutdown the VM.
  2. Use the xe CLI to identify the VDI UUIDs for the VDIs to be moved. If the VM has a DVD drive it's vdi-uuid will be listed as <not in database> and can be ignored.
    xe vbd-list vm-uuid=<VALID_VM_UUID>

    Note

    The vbd-list command will display both the VBD and VDI UUIDs. Be sure to record the VDI UUIDs rather than the VBD UUIDs.
  3. Within XenCenter select the VM's storage tab. For each VDI to be moved, select the VDI and click on the Detach button. This step can also be done using the vbd-destroy CLI command.
  4. Use the vdi-copy command to copy each of the VM's VDIs to be moved to the desired SR.
    xe vdi-copy uuid=<VALID_VDI_UUID> sr-uuid=<VALID_SR_UUID>
  5. Within XenCenter select the VM's storage tab. Use the Attach button and select the VDIs from the new SR. This step can also be done use the vbd-create CLI command.
  6. To delete the original VDIs, within XenCenter select the storage tab of the original SR. The original VDIs will be listed with an empty value for the VM field and can be deleted with the Delete button.
Example:

# xe sr-create host-uuid=8e50bb6e-6848-4314-aa8b-177ec9895d8c content-type=user type=lvm device-config:device=/dev/dm-1 name-label=xen01_vm_stor
# xe vm-list
# xe vbd-list vm-uuid=
#xe vdi-copy uuid=vdi-uuid  sr-uuid=uuid_of_the_storage_where_will_be_copied

No comments:

Post a Comment