2248_evangelists_blog_post_seriesThis is post 8 of 20 in a series of how to’s on Virtualization with Microsoft Hyper-v. For a full list of posts in this series please see Dan Stolts’s original post (o of 20) located here:
http://itproguru.com/expert/2013/03/become-a-virtualization-expert-with-20-days-of-server-virtualization-virtexpert-itproguru-part-0-of-20/

Storage Live Migration:
In Windows Server 2012 and the free Hyper-v Server 2012 Microsoft engineers added the ability to move the storage of your virtual machine while your VM is up and running. For those of you who use VMware, Microsoft storage live migration is like VMware storage vMotion.

This means you can move the virtual hard disks used by a virtual machine to different physical storage while the virtual machine remains running. You heard right – it is not necessary to take a virtual machine offline to move the VMs files to different physical storage.

Storage Live Migration is supported for both VHD and VHDX file types. In Server 2012 VHDX is the new virtual hard drive format that uses a 64k block size to support virtual disks up to 64 TB in size. The old VHD disks use a 512 byte block size and have a max size of 2 TB. These new VHDX files also offer improved disk access speed than the old VHD file format.

Benefits:
The most obvious benefit is the agility of moving or upgrading your backend physical storage without having any VM downtime. The Virtual Machine disk is mirrored to either a local disk or shared storage point where the server can continue to run the VM. Once mirror process is complete, Hyper-V switches the VM to run from destination virtual hard disk. In the case where Hyper-v fails to be able to use the new destination virtual disk, Hyper-v fails back to run on the original source files.

Another benefit of this new technology is that when deleting snapshots from a running VM the snapshot / differencing disk will be merged in while the VM is running. In previous versions of Hyper-v these changes were merged in when the VM was restarted. This had the potential to cause longer than expected reboot times as the VM had to wait to restart until changes were merged. This is not an issue any more!

Another benefit is Shared Nothing Live Migration. When we launched Server 2012 in September of 2012 this is a feature that no other vendor had! Then 3 days later VMware launched version ESX 5.1 which added a similar feature… But for 3 days Hyper-v was the only one to have this. Ok, so what does it do – you ask? In the shared nothing live migration process first it does a storage migration to mirror the virtual hard disk to another server then it does a live migration which mirrors the memory to the new server then switches the running server to run on the new server and removes it from the original server.  Way cool! Moving a running VM from one Hyper-v host server to another without shared storage! Not a preconfigured failover cluster, or a SAN, or a file share. Just two servers with local attached disk. Wow!

How to:
The Live Storage Migration process can be initiated through the Hyper-v Manager MMC or a command line with PowerShell.

From the Hyper-v MMC – you can see under the settings of VM Server1 that the virtual hard disk is currently located under d:\Hyper-v\VHDs\Server1.vhdx

Screen Shot 2013-03-17 at 12.19.27 AM

To initiate a Live Storage Migration – right click on the server then select Move.

Screen Shot 2013-03-17 at 12.20.22 AM

In the Wizard select if you want to move the Virtual Machine or the Storage of the Virtual Machine. Here we choose to move just the storage of the VM.

Screen Shot 2013-03-17 at 12.21.13 AM

You have a choice of moving just the virtual disks or the configuration files also. In my example I chose to move the disks, snapshots,  and configuration file.

Screen Shot 2013-03-17 at 12.22.44 AM

Then choose a folder of where you want to put those files.

Screen Shot 2013-03-17 at 12.24.33 AM

I am moving them from the local hard drive (d:\Hyper-v\VHDs\Server1.vhdx) to a file share (\\hyperv1\VHDS\VirtualMachines\).

Screen Shot 2013-03-17 at 12.25.05 AM

As you can see when I go back into my Server1 configuration the location of the virtual hard disk has now been moved to the file share. This happened while the machine continued to run.

Screen Shot 2013-03-17 at 12.27.13 AM

PowerShell:
This same process can be initiated from a PowerShell Command. Here is the command to accomplish the same move as we did in the wizard above:

Move-VMStorage “Server1″ “\\Hyperv1\VHDs\Virtual Hard Disks\”

And there you have Hyper-v Live Storage Migration.