How To Migrate Parent Disk on Hyper-V 2012

If you are using Microsoft Hyper-V 2012 and “Differencing Disk” you may get trouble when you want to move whole VMs to another location due to “Parent Disk” migration is not so easy. Following is the steps to move parent disk on Hyper-V server.

Preparation

I assume you want to move bunch of virtual machines. First of all you need to get disk list of virtual machines. Following is a script to grab all parent and differencing disks on a Hyper-V server.

$VMs = Get-VM 
Foreach ($VM in $VMs)
{
  $VHDs = Get-VHD -Path $VM.harddrives.path
  foreach ($VHD in $VHDs)
  {
     [pscustomobject]@{
         Name = $VM.name
         VHDType = $VHD.VhdType
         VHD = $VHD.Path
         ParentVHD = $VHD.ParentPath
     }
  }
}

Save it to “Get-vhdParent.ps1”. Launch PowerShell by administrator right. Run following command to get parent disk table.

.Get-vhdParent.ps1 | format-table -autosize

Now you have disk list in hand.

Move parent disks to new location

Parent disk moving is simple. Just copy the parent disk to new location. I suggest make multiple copies if you have large number of virtual machines linked to a parent disk. The reason is if the parent disk failed, at lease it’s not impact to all linked virtual machines. You can also distribute the duplicated parent disks to multiple location to avoid single location failure.

Re-configure parent disks for virtual machine

To be safe, I suggest grab parent disk information again by following command:

Get-VHD -Path VHDPath

Replace “VHDPath” with real differencing disk path of the virtual machine.

The output shows what’s the linked parent disk. Then run the command below to reconfigure parent disk to new location.

Set-VHD -Path VHDPath -ParentPath ParentVHDPath

You should get nothing return if it’s successfully.

If you manage Hyper-V virtual machines by System Center Virtual Machine Manager. The new parent disk is reflected after you right click the virtual machine and do a “Refresh” in System Center Virtual Machine Manager console.