Have thousands of VM's with multiple VMDK's each that are all on different tiers of SAN storage. Looking for an easy way to migrate them all online without an outage to Thick Eager Zero, currently all Thick Lazy Zero. Only successful way I've done this is via Advanced svMotion which works great but surely not easy when you're talking over 4,000 VMDK's. Not sure if there's a way to force or set a default so all svMotions will convert to Eager Zero, or edit something on the vmdk descriptor so it will change automatically once it's moved with svMotion etc... Basically looking for an easy automated way to make this happen and take "user error" out of the process
Thanks!
Note: Discussion successfully moved from VMware vCenter™ to Automation Tools
Hello, kcompton-
You can use PowerCLI to achieve such a conversion. Like you said, you can perform an sVMotion of a disk and specify a new storage format. PowerCLI's Move-VM and Move-HardDisk cmdlets each have a parameter that allow for specifying the storage format of the hard disk(s) after the move. An example of moving a VM and setting its storage format to eager zeroed thick:
Move-VM myVM0 -Datastore myDstore0 -DiskStorageFormat EagerZeroedThick -RunAsync
So, you can do this as desired by host, by cluster, by datastore, by [whatever]. That get you started?
The problem I have is I can't move an entire VM to a single datastore unfortunately. Most our VM's have tiered storage (Gold, Silver, Bronze and Logs) so I would have to move each drive separately
Be nice if I could put a datastore in maintenance mode and have it convert everything to eagerthick while moving the VM's to another datastore in the cluster...
Hello, kcompton-
Old thread, I know, but, I wanted to mention the Evacuate Datastore code that Allen Crawford wrote about in his vNugglets.com post at http://www.vnugglets.com/2012/12/evacuating-vms-and-templates-from.html. This will allow for the "moving each disk separately" -- it moves only virtual disks and VM config files that reside on the source datastore.
And, that code does not address changing the storageformat of the virtual disks during the move, but it seems that you could achieve that by adding another property to the VMware.Vim.VirtualMachineRelocateSpecDiskLocator object that is used in said code for the relocations. Let us know if you go that avenue, and how it goes.
i managed it with an input list. but you could do it also with an query for thick to push it to an variable.
important is also that enough Space is available on the destination Datastore. (so change the FreeSpaceGB in my code if you use it)
connect-viserver xxxx
$csvpath = Read-Host ("Please input Path to csv")
$vms = import-csv $csvpath
foreach ($vm in $vms){
$sourceDS = get-vm $vm.name |get-datastore |Select name
$cluster = get-vm $vm.name |get-cluster | Select name
$destDS = get-cluster $cluster.name |get-vmhost| get-datastore |Sort FreeSpaceGB |where-object {$_.name -ne $sourceDs.name -and $_.name -notmatch "local" -and $_.FreeSpaceGB -gt 80} |Select -Last 1 | Select Name
write-host -fore Cyan `n`t "Starting Migration" $VM.name "from" $sourceDS.name "to" $DestDS.name
move-vm $vm.name -Datastore $destDS.name -DiskStorageFormat EagerZeroedThick
write-host -fore Cyan `n`t "Finished migrating" $VM.name "Moving back...to" $sourceDS.name
move-vm $vm.name -Datastore $sourceDS.name
}