Register for Semperis' Hybrid Identity Protection (HIP) Conference - June 30 - July 1 Register for Semperis' Hybrid Identity Protection (HIP) Conference - June 30 - July 1

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.

Related Topics:

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.

Register for the Hybrid Identity Protection (HIP) Europe Conference!

Hybrid Identity Protection (HIP) Europe 2021 - Virtual Conference

Mobile workforces, cloud applications, and digitalization are changing every aspect of the modern enterprise. And with radical transformation come new business risks. Hybrid Identity Protection (HIP) is the premier educational forum for identity-centric practitioners. At the inaugural HIP Europe, join your local IAM experts and Microsoft MVPs to learn all the latest from the Hybrid Identity world.