How Storage vMotion works under the hood

VMware makes moving a VM from one datastore to another simple with Storage vMotion, but the details of how the feature works are more complex.

How does Storage vMotion work?

Storage vMotion is a great feature to use when you need to move VMs from one datastore to another. For instance, you may need to move all of your VMs to a newly purchased array. You can use Storage vMotion to do this migration without any downtime and with just a few clicks. Another use of Storage vMotion could be to convert workloads from thick provisioned disks to thin provisioned disks or vice-versa.

Now how does Storage vMotion work? The process appears to be quite simple on the surface, but under the covers, there is a lot of complex work going. In vSphere 4.1 and prior versions, the process used was called Changed Block Tracking (CBT), which basically copied all blocks the first time and then used the information within CBT to copy any blocks that had changed since the first copy.

In versions 5.0 and later, the process uses Mirror Mode. Mirror Mode splits the I/O between the source and destination, which means that every write I/O goes to both locations. This makes the process faster because the blocks only need to be copied once. The other cool thing about this is that if your storage array supports vStorage API for Array Integration, then Storage vMotion will use these capabilities as well.

Let's break down the actual process behind the scenes that makes all of this work.

  1. The source working folder (vmx, logs, etc.) is copied to the target datastore.
  2. A shadow VM is created and started on the target datastore using the copied files, but it is paused and prepared to receive copied blocks. This shadow VM is created to failsafe in the chance that the VM's home folder is moved.
  3. The mirror driver starts copying write I/O blocks already copied to the target datastore.
  4. The VM's disk files are copied to the target datastore and completed while the I/O is being mirrored in a single pass.
  5. The source VM is suspended and execution is resumed by the shadow VM.
  6. The source VM's folder and disk files are deleted from the source datastore.

How do you use Storage vMotion? The process is quite simple, all you need to do is right-click on a VM and select migrate, change datastore, select a virtual disk format (if you want to change), select new datastore, click next and then finish.  Yes, it is that simple. Now go and do some Storage vMotioning.

Dig Deeper on P2V, V2V and V2P migration