HyperV now supports online resizing of VHDX. A VHDX disk which is used by a VM can be resized and without restarting the VM, This is really an important feature which will allow flexibility on expending or shrinking VHDX on the fly as per the requirement.
VHDX – the ability to expand and shrink virtual hard disks is exclusive to virtual hard disks that are using the .vhdx file format. Online resizing is supported for VHDX disk types, including fixed, differencing, and dynamic disks. Virtual hard disks that use the .vhd file format are not supported for resizing operations.
SCSI controller – the ability to expand or shrink the capacity of a virtual hard disk is exclusive to .vhdx files that are attached to a SCSI controller. VHDX files that are attached to an IDE controller are not supported.
Irrespective of the Generations – Gen1 or Gen2, Online Resizing will work fine if the prerequisites are met.
Lets try this on a Gen1 VM with a SCSI Disk.
The DISK1 in the above screen shot is a SCISI Disk
Get-VM VMName |Get-VMHardDiskDrive -ControllerType SCSI |Resize-VHD -SizeBytes 500GB
Now the VHDX is expanded. As the GUST OS on this VM is Windows 2008 R2, To get this change reflected on the VM, From DISK Management , Initiate a RESCAN. With Windows Server 2012, This change will get reflected immediately without a rescan.
If its a GEN2 VM, Its more easy as the default DISK which is getting created is a SCSI Disk. So even a System Drive can be expanded.
Get-VM VMName |Get-VMHardDiskDrive -ControllerType SCSI |Resize-VHD -SizeBytes 1TB
If its a Windows Server 2012 VM, the change will get reflected immediately and don’t need a rescan.
The current C drive which is 100 GB can now expanded to start using the added space.
From Disk Management -> Right Click on the volume which needs to be extended
Select Extend Volume
The maximum available space will be set by default , how ever this could be reduced as per the requirement.
And now the C Drive is 1 TB.