VHDX is a new format of virtual hard disks that appeared in Windows Server 2012. Disks in VHDX format have a number of advantages and today I will describe several methods of converting a disk from VHD into VHDX.
[tab title=”Contents of this article”]
Advantage of VHDX format
To begin with, there are a few words about the advantages of the new format:
- VHDX format allows to create disks up to 64TB whereas VHD can handle 2TB max.
- VHDX supports working with 4KB sectors. It allows to store VHDX files on large disks (over 2TB) using Advance Format (breaking into physical 4 KB sectors).
- VHDX uses logging. All changes in the metadata are written to the log before making changes in the metadata table. If a failure occurs while making changes to the table, the log keeps the unfinished transactions that allow to complete changes in the table and restore file integrity. It makes the VHDX format more fail tolerant and prevents possible data loss during power outages.
- Custom metadata are supported. VHDX has a special user section where you can store data on the contents of the virtual disk, e.g. information on the installed OS and apps. User section allows to store any descriptive metadata.
- VHDX format supports unmap operations and allows to free the unused space dynamically after removing data from the virtual disk. It allows to use disk space on a storage device more effectively.
If you want to get all these advantages, there is an opportunity to convert the existing virtual disks from VHD into VHDX. You can do it in the graphic snap-in Hyper-V Manager or in PowerShell console. But before you start, remember that:
- When converting, a new file of the same size as the source file is created, so you have to check if there is enough free space;
- A downtime is inevitable during convertation process. If the disk being converted is connected to a virtual machine, the machine has to be stopped.
How to Convert into VHDX Using Hyper-V Manager
Open the snap-in Hyper-V Manager and click Edit Disk option in the Actions list.
Enter the name and the path to the new VHDX.
After that we get a new disk that can be mounted to a virtual machine and used. Meanwhile, the old disk is not removed. You have to do it manually.
How to Convert into VHDX Using PowerShell
To convert a disk in PowerShell, use the following command:
Convert-VHD -Path ″E:\Hyper-V\winsrv2012r2.vhd″ -VHDType Fixed -DestinationPath ″E:\Hyper-V\new_winsrv2012r2.vhdx″ -DeleteSource
This command creates a new fixed-sized disk in the VHDX format and the -DeleteSource key deletes the source file.
You can convert in both directions. The backward conversion is possible using the following command:
Convert-VHD -Path ″E:\Hyper-V\winsrv2012r2.vhdx″ -VHDType Fixed -DestinationPath ″E:\Hyper-V\new_win2012.vhd″ -DeleteSource
To sum it up, I remind you that you can place any OS in the VHDX file, but this file can only be mounted in Windows Server 2012 / Windows 8 or higher. The earlier OSs do not support VHDX.