VHDX files are Microsoft's newer version of their original Virtual Hard Disk files, both of which are used in Hyper-V...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
2012. Files in VHDX format offer better performance and functionality, for example, the ability to support drives up to 64 TB instead of a mere 2 TB. Another benefit of the VHDX format is being able to change the size of the virtual disk while the virtual machine is still running.
To change the size of a virtual hard disk under Microsoft's previous VHD format, you would need to shut down your virtual machine (VM). VHDX removes that issue -- and the downtime -- by allowing online resizing. You can change the size of the virtual hard disk without your users even knowing.
The online resizing feature is available to all three VHDX disk types: fixed, differencing and dynamic. Because of these new options, it's worth reconsidering how you set up your VMs. This makes the fixed disk option more favorable than it was previously.
Fixed disks are great if the amount of data on your virtual disk stays static, while dynamic disks expand as additional storage is needed, with a small performance hit. With dynamic disks there is the risk of running out of physical disk space, whereas fixed disks can now be expanded (or even shrunk) as required.
Generally there is no need to shrink a virtual disk, unless you're desperately low on physical disk space, but the process of shrinking and expanding is almost the same. A caveat with shrinking is that you need to first shrink the disk on the VM via Disk Management, which results in unallocated disk space, and then you can shrink the same way that you would expand.
For dynamic disks there is also a compact option, which optimizes the disk size by rearranging blocks and reclaiming unused blocks, and is worthwhile using on a disk that has drastically changed in size.
The process of resizing a VHDX file can be accomplished through either the graphical user interface or PowerShell. If your VM is not in a cluster, you need to use Hyper-V Manager to make the change, but if it's a clustered VM, the options will be greyed out and you'll need to use Failover Cluster Manager instead.
Once in the correct management console -- regardless of which one you choose -- the process is very similar. Start by going to the settings of the VM, choose the hard drive you want to resize and click Edit. This will launch the Edit Virtual Hard Disk Wizard and, depending on the scenario, you will see up to three options: compact, expand or shrink. You then need to specify the new size of the disk and click Finish to let the wizard complete the task.
To perform the same function using PowerShell, there is just a single command needed, called Resize-VHD. Here's an example of the simple commands:
Resize-VHD -path D:\VMs\Disk3.vhdx -SizeBytes -500GB
This would either expand or shrink the virtual disk to 500 GB. Compacting a dynamic disk is just as easy, with a command such as this:
Optimize-VHD -Path C:\VMs\Disk3.vhdx -Mode Full
After a disk has been expanded through GUI or PowerShell, you'll need to jump on the VM and expand the disk through the Disk Management console. The Extend Volume option is used on the existing volume, which can then be changed to use the full virtual disk capacity.
Resizing virtual disks in Hyper-V is an easy process, and even more convenient with the added feature of being able to do it in online mode. If you're still stuck with the VHD format, it may be worth migrating some of your VMs to the newer VHDX format for flexibility in the future.