Step-by-step Hyper-V Storage Live Migration

In our daily work, we often encounter situations where migrating Hyper-V VMs to different storage is necessary, ideally without downtime. Starting with Windows Server 2012, Microsoft introduced storage live migration, a feature that allows us to move VM storage while the VM remains running. For versions prior to Windows Server 2012, a maintenance window is required to shut down the VMs and migrate their disks and configuration files to new storage.

Hyper-V storage live migration supports transfers between independent disks, central storage, or shared folders. However, it does not currently support migrations between Hyper-V hosts or when the VM’s storage is directly attached to a physical disk.

If you are using SCVMM, the process is streamlined. Without an SCVMM license, you can still perform storage live migrations easily using the Hyper-V Manager console, Failover Cluster Manager, or even more efficiently, through PowerShell.

There are a few situations when we want to migrate our Hyper-V VMs to a different storage:

  • Storage starts to run low on space. Usually this is the most common situation.
  • Storage needs to be put into maintenance mode because of a hardware issue, upgrade, replace.
  • Some VMs started to do a lot of I/O operations and are ruining the storage performance affecting the rest of the VMs sitting on the same storage. Migration is needed in order to balance the load.
  • VMs are running on individual disks and hosts and need to be consolidated into a Hyper-V Cluster.

 

1. Hyper-V Storage Live Migration using Hyper-V Manager

Depending on how many storage migrations we need to do simultaneously, we can either increase or decrease the Simultaneous storage migrations number from the Hyper-V Settings, and by default we can do two simultaneous migrations.

Once we set that up, all we need to do is right-click the VM for which we are going to migrate its storage and choose Move from the menu that opens up.

This will launch the Move Wizard, and on the first screen just hit Next to continue.

On the second screen of the wizard, the Choose Move Type screen, we have two options:

  • Move the virtual machine – This will allow us to move not just the virtual disks and config files, but also the VM itself.
  • Move the virtual machine’s storage – This will give us the options to migrate the virtual machine’s virtual disks and config files.

The first option requires a few more configurations in order to work and it’s out of the scope for this article, so let’s click on the second one and continue the wizard.

On this next screen we also have a few more options to choose from:

  • Move all of the virtual machine’s data to a single location – This will move all of the virtual machine’s files like virtual disks (VHDs), snapshot files, config files into a single location.
  • Move the virtual machine’s data to different locations – We will get the option to select the location for each component (VHD/X, snapshots, config files) in case we need to separate them.
  • Move only the virtual machine’s hard disks – This will move/migrate only the virtual disks ignoring the other components.

In most of the cases, only the VHD/X disks will need to be migrated, but there are situations where the rest of the files will also be needed. For the purpose of this article we will go with the latest option, Move only the virtual machine’s virtual hard disks.

In my example here, I will migrate only one of the virtual machine’s disk to a different/faster storage because of the high I/O leaving the OS virtual disk untouched and unmoved. As you can see we have the option to migrate all of the virtual disks or just some of them.

Select the virtual disk(s) new location on the Hyper-V host by clicking the Browse button and when you are done, hit Next.

On the Summary screen we have a short description of the operations that are going to happen once we click the Finish button. If everything looks good, hit Finish to begin the migration.

Depending on the size of the virtual disk(s), the operation can take quite some time. This is not a problem since the migration is happening while the virtual machine is running. The only inconvenient that can sometimes occur is a bit of lag inside the guest OS.

And sure enough, our virtual disk was migrated successfully on the new storage.

The OS virtual disk is still in the same place since we choose during the Migrate Wizard not to migrate it.

2. Hyper-V Storage Live Migration using Failover Cluster Manager

The process is pretty much the same. Open the Failover Cluster Manager, right-click the VM and choose Move > Virtual Machine Storage.

The Move Storage Virtual Machine window will appear, allowing us to migrate the virtual machine’s files. Interestingly, Microsoft has omitted a New Folder button in this window, which would have been useful for organizing files. If you need to create a new folder, you’ll have to do so directly on the Hypervisor. In this example, I’ve already created a folder within the Cluster Shared Volume, where I will migrate all the virtual machine’s files.


To migrate files, simply drag the ones you want to move to the bottom section of the window. In this example, I’m continuing from the previous section, where the virtual machine has one disk in the default location and another on separate storage. During live migration, both virtual disks will be relocated to a folder within the Cluster Shared Volume. Additionally, you can migrate between different Cluster Shared Volumes based on your requirements.

Once we click the Start button, the live migration begins and we can see that in the Information column in the Failover Cluster Manager console.

And once again, Microsoft messed this up. For a more detailed view about the migration we have to open another console, the Hyper-V Manager console where we can see the progress of the migration.

Depending on the size of the virtual disks and the storage speed, this might take a while, but once it is done we should have all the file in the chosen destination.

Another way to verify if the migration was a success, is by opening the virtual machine’s settings. As you can see, the virtual disks resides on the Cluster Shared Volume now.

3. Hyper-V Storage Live Migration using SCVMM

Migrating virtual machine’s storage using SCVMM is not much of a difference compared to the other options we just discussed. Now off course, you will need to have System Center Virtual Machine Manager (SCVMM) already installed and configured, and once this was taken care of, all we need to do is right-click the VM and choose Migrate Storage.

This will open the Migrate Storage Wizard, which will give us the option to either migrate all the virtual machine(s)  files or just the VHDs.

If we want to migrate the configuration files of our VM(s), all we have to do is hit the Browse button from the Storage Location for VM configuration box. If the VM has multiple virtual disks, we get the option to choose which one to migrate to a different storage and we can do that by selecting the option Allow VHDs to be placed individually.

By clicking the Browse button in the Disks section we get the option to select the destination storage for our VM disk(s). What I really like about this window is that it gives us the option to open the destination location in Explorer so we can create folders for better organizing our VM files/disks. Just click the Explore directory link in the bottom left corner to see it in action.

Once we selected the destination storage for our disk(s) just hit Next to continue.

And we get to the Summary screen where we can either see the actual PowerShell script that is used by the wizard for this operation, or we can just click the Move button to start the storage live migration for the selected VM.

If your Job window is not disabled, it will pop-up and show the actual move progress and the steps it takes for the this operation.

If everything worked out great, we will only see green check marks with a Completed message.

To verify it actually worked, we can open the properties of the VM and look where the disk is located. And sure enough, the migration did indeed succeeded.

 

4. Hyper-V Storage Live Migration using PowerShell

If we want to automate all this, we can do storage live migrations using PowerShell. A simple command line to move all the VM files (snapshots, VHDs, config files) to a different datastore will be:

Move-VMStorage -VMName "VM NAME" -DestinationStoragePath "DESTINATION DATASTORE"

In case we want to move just the disks, the command line becomes a bit more complicated. We have to explicitly type the source and the destination path of the VHD(s).

Move-VMStorage -VMName "VM NAME" -Vhds @{"SourceFilePath"="E:>ROCLJVKRSCCM > ROCLJVKRSCCM_DATA.vhdx";"DestinationFilePath"="C:> ClusterStorageVolume1 > ROCLJVKRSCCM > ROCLJVKRSCCM_DATA.vhdx"}

Off course, we can get more complicated then this, especially if we enter the automation world, but I just wanted to give you a simple example of how it works.

Summary

Having the option to migrate virtual machines resources while running was a must. Not every time we can schedule for a downtime when our storage get’s full or get’s into trouble, but even if we do, it is disrupting the live environment. As you saw in the article, the newer versions of Microsoft server OS have no issues doing migrations while the virtual machines are online. Use it and let me know your experience with it.

80%
Awesome
  • Design
Hyper VLive MigrationMicrosoftStoragevirtualization
Comments (0)
Add Comment