TECHNIG
Gateway for IT Experts and Tech Geeks

How to Convert VHD to VHDX Using Hyper-V and PowerShell?

Virtual Hard Disk (VHD) is the hard disk format of Microsoft Hyper-v, a compatible hard disk format with Windows Server 2008 and Hyper-v server 2008. But in Windows Server 2012, Microsoft has changed the VHD format to VHDX, like the old file documents (.doc) to .docx. So here I’m going to show you how to convert VHD to VHDX using Hyper-v manager and PowerShell command line.

Before starting conversion process, once read the benefits and new features of VHDX from Hyper-V Virtual Hard Disk Format Overview

The main new features of the VHDX format are:

  • Support for virtual hard disk storage capacity of up to 64 TB.
  • Protection against data corruption during power failures by logging updates to the VHDX metadata structures.
  • Improved alignment of the virtual hard disk format to work well on large sector disks.

The VHDX format also provides the following features:

  • Larger block sizes for dynamic and differencing disks, which allows these disks to attune to the needs of the workload.
  • A 4-KB logical sector virtual disk that allows for increased performance when used by applications and workloads that are designed for 4-KB sectors.
  • The ability to store custom metadata about the file that the user might want to record, such as operating system version or patches applied.
  • Efficiency in representing data (also known as “trim”), which results in smaller file size and allows the underlying physical storage device to reclaim unused space. (Trim requires physical disks directly attached to a virtual machine or SCSI disks, and trim-compatible hardware.)

Convert VHD to VHDX with hyper-v manager is the graphical method and is easy for beginner to Virtualization with hyper-v. Do it like the below step by step guides.

Convert VHD to VHDX with Hyper-v Manager

The first method is using Hyper-v Manager to convert vhd to vhdx. So open your hyper-v manager and click the Action then click Edit disk or from right side click Edit Disk.

Hyper-v Manager
Hyper-v Manager

When the Edit Virtual Hard Disk Wizard opened, click browse and select the virtual hard disk files.

Edit Virtual Hard Disk
Edit Virtual Hard Disk

When you select the existing .vhd file, click Next.

Convert VHD to VHDX
Convert VHD to VHDX

On the Choose Action page, select Convert and click Next.

Convert VHD Files
Convert VHD Files

On the Choose Disk Format page, select VHDX and click Next.

Convert Virtual Hard Disk
Convert Virtual Hard Disk

Now, on the Configure Disk page click Browse and select the directory, where you want to save the vhdx file and then click Next.

Configure Virtual Hard Disk
Configure Virtual Hard Disk

Finally on the Summary page click Finish button to complete the conversion of VHD to VHDX.

Completing the Edit Virtual Hard Disk Wizard
Completing the Edit Virtual Hard Disk Wizard

Yes, the vhd format converted successfully to vhdx format.

Convert VHD to VHDX Result
Convert VHD to VHDX Result

Go to virtual hard disk directory and see the converted vhdx file.

Convert VHD to VHDX with PowerShell

Now try to convert vhd to vhdx with Windows Powershell. It is also easy and just requires one line command of convert-VHD. Remember, before starting conversion of vhd, you must turn off all you guest computers in Hyper-v environment.

1. Convert Single Virtual Hard Disk

convert a single vhd to vhdx with the following command.

PS C:\> Convert-VHD -Path 'E:\Virtual Hard Disk-1.vhd' -DestinationPath E:\Virtual-HD.vhdx

Convert VHD to VHDX with PowerShell
Convert VHD to VHDX with PowerShell

The Convert-VHD is the main command for vhd conversion and the -Path is the directory of vhd files, and the -DestinationPath is the directory where you want to save the converted vhd to vhdx file.

OK, done successfully, now check the result with get-childitem command.

PS C:\> Get-ChildItem E:\*.vhdx

VHDX Result
VHDX Result

2. Convert Multiple Virtual Hard Disks 

Convert multiple VHD files to VHDX using with the following method. Here I have 3 vhd files which I created for test.

PS C:\> Get-ChildItem E:\*.vhd

PowerShell Get-ChildItem
PowerShell Get-ChildItem

OK, that’s all three virtual hard disks with vhd format. Let’s convert them with one command at the same time.

PS C:\> Get-ChildItem E:\*.vhd | ForEach-Object {Convert-VHD -path $_.fullname -destinationpath ("E:\"+ $_.basename + ".vhdx") }

Convert Multiple VHD
Convert Multiple VHD

The two new properties within this command line, $_.fullname will give us the directory and file name of VHD files with extension. And the next $_.basename is just get the name of objects without extension in order to add new vhdx extension to converted virtual hard disks.

So the result must be like the below screenshot.

Result of Multiple VHD Conversion
Result of Multiple VHD Conversion

OK, hope you get something about convert vhd to vhdx using Hyper-v manager and PowerShell command line. I know we can do more with PowerShell hyper-v module, but this post is only for conversion of vhd to vhdx. If you need more help or want to ask question, feel free and ask through comment.

1 Comment
  1. Niaz Mohammad says

    this is good way

Leave A Reply

Your email address will not be published.