Converting a Hyper-V Pass-Through Disk to a VHDX

How do I convert a Hyper-V pass-through disk to a VHDX disk?

After learning about the merits of VHDX format virtual hard disks, you might decide to convert any physical pass-through disks to VHDX on your Windows Server 2012 hosts. Luckily, Microsoft provides us with a way to do this in Hyper-V Manager.

The first step is the tricky one: The virtual machine must not use the pass-through disk so that you can mount the disk exclusively on a machine that has the Hyper-V Manager installed. This will require a maintenance window.
Next, open Disk Management on the Hyper-V Manager machine and note the disk number. In our example below it is Disk 3.
Hyper-V Passthrough disk
Open up Hyper-V Manager, and select New >Hard Disk under Actions. This opens the New Virtual Hard Disk Wizard.
Select the VHDX format, choose the type (Fixed Size or Dynamically Expanding), and choose the name and location of the new VHDX file.
The crucial step in the process comes in the Configure Disk screen. Choose Copy the Contents of the Specified Physical Disk, and select the disk that you identified in Disk Management (again, in this example, it’s Disk 3).
The Hyper-V VHD Wizard
On completion of the wizard, a new VHDX file will be created. You can then edit the properties of the machine and replace the pass-through disk with the VHDX file. Remember to remove the disk from Failover Cluster Manager if the virtual machine was highly available.

Converting a Hyper-V Pass-Through Disk Using PowerShell

You can also do this conversion using PowerShell. The first step is to identify the physical disk. Use Get-Disk to list the disks. Again, in this example the disk ID is 3.
Next you will run New-VHD to create a new VHDX file, then use the -SourceDisk flag to point at a physical disk to convert. The following example converts physical disk 3 into a dynamically expanding VHDX:

​New-VHD -Path "D:\VHD\Converted.VHDX" -Dynamic –SourceDisk 3

The above approaches will create a VHDX file with a physical sector size of 4K and a logical sector size of 512 bytes. Using the -SourceDisk flag with New-VHD prevents the use of the -LogicalSectorSize flag. If you want to create a VHDX with a 4K logical sector size then you will have to create a new (and blank) VHDX, attach it, and copy (or restore from backup) the files from the pass-through disk.
Some suggestions:

  • Your pass-through disk might reside on a SAN that supports LUN cloning. Create a clone of the LUN and test the process and the results. This will also tell you how long the production conversion will take.
  • Presence of Offloaded Data Transfer (ODX) might accelerate the conversion process if the pass-through disk and the new VHDX reside on the same SAN.