Storage vMotion is one of the most astonishing features that VMware brought to the universe of virtualization.
I’m certain that storage Admins will admit the migrating Data from on storage array to another can be quite complicated. On physical host it is almost impossible to do such migration without any downtime.
Well, Storage vMotion accomplish the full migration of VMs Virtual Disks without downtime! Some performance degradation during the migration but no downtime.
1 year ago we had to change the storage array used by my Virtual infrastructure (vSphere 4.0):
More than 60 hosts using 50 TB of disk space for ~500 VMs
I said. Ok let’s Storage vMotion them to the new array.
Even if, now you can start Storage vMotion through the VI Client. For more than 500 VMs it can take some times!
Ok let’s go with some scripting then.
PowerCli is the absolute solution for Virtual Admins. Honestly it is so powerful.
I made this script:
In the script you have to change the credential used to connect to the vCenter server, set the correct vCenter address and set a percentage of reservation in the destination Datastore. This % reservation will avoid moving a VMs real usage if it is above the reservation + destination Datastore’s free space.
Basically you enter the Source Datastore name and Destination Datastore name.
Then it will get the VMs located in the source Datastore.
And for each VM it will first check if the UsedSpaceGB of the VM is greater or equal of the FreeSpace including the reservation specified in the command of the Dest. Datastore. If it is above it exits.
Then it will check if the ProvisionedSpaceGB of the VM is greater or equal of the FreeSpace including the reservation specified in the command of the Dest. Datastore. If it is above it warns you and ask if you want to continue or exit.
Last check is if the VM has snaphots. If it has it will skip it and go for the next one.
Once the storage vMotion of the VM is complete, it will go for the next one, etc…
This script only does VMs without snapshots not the templates.
I used this script to migrate my entire infrastructure successfully without any issue and with the minimal amount of effort.
Piece of cake