Sometimes it’s necessary to only migrate a single hard disk from a VM. This is the case when someone adds two 1 TB VMDK’s and fills them up completely. The maximum size of a VMFS datastore is 2TB minus 512 bytes. So in this case the datastore will be completely filled with no space left to keep the VM running. So if you want to migrate just one hard disk to make sure the VMFS datastore will not fill up. You can use the vSphere client or PowerCLI to do perform this “advanced” Storage vMotion.
Note: if you want to reclaim your “wasted” storage back from your SAN, you have to recycle the whole datastore. So you have to migrate the other hard disks and configuration files as well.
vSphere Client
Start the Migrate Virtual Machine wizard and select datastore:
In the Select Datastore wizard, click the Advanced button:
Now you’re able to select the hard disk you want to migrate and the datastore. Don’t change the other settings:
Review the summary and press finish to execute this Storage vMotion:
PowerCLI
Or you can use the following PowerCLI one-liner to migrate the Hard disk:
Get-HardDisk -vm <vmname> | Where {$_.Name -eq "Hard disk <#>"} | ` % {Set-HardDisk -HardDisk $_ -Datastore "<datastore>" -Confirm:$false}
The following output will be generated:
Nice!
Gabriel
I tried this and Iam getting the error “a general system error occured , failed to start disk migration”. Do you know what can will be the reason?.
Reblogged this on Myles Gray.
Lovely trick! I didn’t know it.
Suppose I have two esxi hosts and I am using the both machine’s HDD as their datastore. So can I do vmotion in this environment where there is no shared storage?
Yes, if you are running vSphere 5.5 or higher it’s possible to Storage vMotion the virtual machines. You have to use the vSphere Web Client to perform the action. I assume you have a vCenter server running because that’s a requirement too.
What about on a computer running Ubuntu 18.04