Manage Learn to apply best practices and optimize your operations.

Resizing a VHDX file without missing a beat

VHD files reigned supreme in Hyper-V -- until Microsoft came out with VHDX files. Knowing how to resize all three disk types of VHDX files can be beneficial in your environment.

VHDX files are Microsoft's newer version of their original Virtual Hard Disk files, both of which are used in Hyper-V...

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.

Edit Virtual Hard Disk WizardInside the ‘Edit Virtual Hard Disk Wizard' you will specify the new size of the disk.

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.

This was last published in June 2014

Dig Deeper on Capacity planning for virtualization

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

You forget to mention a critical flaw: resizing or optimizing a vhdx requires that it be offline. That does not jive with the article title saying "without missing a beat".
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close