Storage VMotion – The PowerCLI way

Ok, we all know what Storage VMotion is…

Enable live migration of virtual machine disk files across storage arrays. VMware Storage VMotion lets you relocate virtual machine disk files between and across shared storage locations while maintaining continuous service availability and complete transaction integrity.

VMware also give us some nice detail telling us how Storage VMotion works…


image

  1. Before moving disk files, Storage VMotion creates a new virtual machine home directory for the virtual machine in the destination datastore.
  2. Next, a new instance of the virtual machine is created. Its configuration is kept in the new datastore.
  3. Storage VMotion then creates a child disk for each virtual machine disk that is being moved to capture a copy of write activity, while the parent disk is in read only mode.
  4. The original parent disk is copied to the new storage location.
  5. The child disk is re-parented to the newly copied parent disk in the new location.
  6. When the transfer to the new copy of the virtual machine is completed, and the original instance is shut down. Then, the original virtual machine home is deleted from VMware vStorage VMFS at the source location.

But if you are not lucky enough to be running vSphere where there is a fully supported integrated Virtual Infrastructure client option for SVMotion ?

There is the VMware unsupported method which most of us are unable to use in a corporate environment and especially not in production – SVMotion Plugin

Or there is the Remote CLI method which to me seams a little hard, well compared to the next one I’m going to show you.

Did you know you can also use SVMotion via PowerCLI ?!?  Well you can and look how easy it is:

Get-VM MyVM |Move-VM -datastore (Get-datastore MyDatastore)

The Move-VM Cmdlet covers a multiple of sins, lets check some out, you want VMotion:

Get-VM -Name MyVM |Move-VM -Destination (Get-VMHost MyHost)

And also what you would expect, moving a VM to a new folder:

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-Folder -Name Production)

And moving a VM to a new resource pool, what a multifunctional cmdlet this is !

Move-VM -VM (Get-VM -Name MyVM)-Destination (Get-ResourcePool -Name Important)

7 thoughts on “Storage VMotion – The PowerCLI way”

  1. Can you specify the disk format desired? I’d like to svmo all my pre-prod guests as thin provisioned. There must be a parameter since the GUI allows you to specify the format.

  2. Carter thanks for the tips, I wrote the article before you could specify them from name, in the older version of PowerCLI you had to do it this way – great improvement by the way.

    I didnt know the behind the scenes bit, thats good to know.

    Thanks for the comment !

  3. Just a nit to pick, in the first example you don’t need the second Get-Datastore bit you can just specify the name.

    Now the interesting part: Actually -Destination can accept strings directly as well. If you do that, behind the scenes PowerCLI will try to match it against a datacenter then cluster, then resource pool, all the way down the line. So you can either just use the object’s name or if you want to be extra sure your VMs will end up in the right place you can use the style of the last 3 examples above.

Leave a Reply