Hey,
because of the migration to a new storage, I need to migrate the VMDKs of my VMs to a new storage.
For normal disks, I will just do a storage vMotion from old_storage to new_storage.
During this, on the new storage, it will create a new directory named after the VM and place the disk in there.
But I also have "special" vmdk attached to some VMs. They live in a /shared/a/b/c path of my old_storage.
When doing a normal vMotion, it would move those as well into the directory of the other VM-disks.
Is there a way to move those special disks into the same /shared/a/b/c subdirectory on my new_storage?
I did some additional testing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
you can export the HDDs, copy them to the new path and mount them by hand on the VMs
ARomeo
Provided both are visible on the ESXi nodes, you could use the MoveVirtualDisk method directly.
There is also a CopyVirtualDisk method if you want to play it safe.
Have a look at Re: Move, Remove, or Copy an orphaned VMDK all result in a Flat file?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey,
thanks a lot for that hint.
But I guess, exporting/copying would only work, when detaching the VMDKs from the VM or shutting the VM down.
I need to do those moves, while the VMs keep running and the VMDKs being mounted writeable to them.
The old_storage and new_storage are both visible to all ESXi hosts.
Regarding the MoveVirtualDisk. When reading the documentation, I wasn't sure if this is possible for a running VM. Is it?
Well, apparently, the Disks I want to keep separate are no VDisks, at least a Get-VDisk -Datastore "old_datastore" does not show any
Thanks so far
No, MoveVirtualDisk is not a svMotion.
You can use the RelocateVM method with only 1 or more specific disks.
That would work for a powered on VM as well.
There is some sample code to be found in Re: Move only config files of a vm
In your case you would only specify the specific harddisks
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LucD,
I had a look at the sample code you linked.
There it is about only moving individual disks, which is super cool.
But as far as I understood the code, there you also can only specify a destination datastore.
Not a custom path on the destination data store:
Get-HardDisk -VM $vm | %{
if($_.Name -ne 'Hard disk 1'){
$disk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator
$disk.diskId = $_.Extensiondata.Key
$disk.datastore = $_.Extensiondata.Backing.Datastore
$spec.disk += $disk
}
}
Would it be possible to also somehow inject a custom path there?
If you use the diskBackInfo property in there, you can use the VirtualDeviceFileBackingInfo, which has a Filename property.
I haven't used that recently, but that allows you to specify the path where the VMDK should be relocated to,
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LucD,
sorry for the delayed answer.
I read about the diskBackInfo and the VirtualDeviceFileBackingInfo.
But I did not found a way to specify a diskBackInfo for a svMotion.
My path looks like this:
- VirtualMachineRelocateSpecDiskLocator
But to me it looks the VirtualMachineRelocateSpec I can only specify when doing a RelocateVM, which afaik does not work while the VM is powered on.
Or do I miss something here?
Thanks a lot in advance
I did some additional testing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LucD,
thanks a lot for the additional investigation you did.
Sad to hear that this is not possible, but now we have certainty and can check if we find other ways to migrate the data.