Mastering Windows Server 2016 Hyper-V

(Romina) #1

Dynamic VHDX Resize


Prior to Windows Server 2012 R2, any changes to the size of a VHDX file required the
virtual machine using the VHDX file to be shut down. There was no way to resize a
VHDX file dynamically while the virtual machine was still running, which some
organizations found to be a pain point. Windows Server 2012 R2 introduced dynamic
resize for both increasing and decreasing the size of a file. The requirements for
dynamic resize are as follows:


Must    be  a   VHDX    file.   Dynamic resize  is  not supported   for VHD files.
Must be connected to the SCSI controller. Dynamic resize is not supported for
virtual hard disks connected to the IDE controller.

Performing a dynamic resize is exactly the same as performing an offline resize
operation:


1 . Within  Hyper-V Manager,    select  the Edit    Disk    option.
2 . Click Next on the Edit Virtual Hard Disk Wizard introduction page.
3 . Select the VHDX file to modify (remember, the VM using it can still be running),
and then click Next.
4 . Select the Expand or Shrink option, depending on your desired action, and then
click Next.
5 . If you selected Shrink, the minimum possible size will be shown in brackets. If you
selected Expand, the maximum possible size will be shown in brackets. Enter the
new size, and click Next.
6 . Click Finish to perform the resize.

If you performed an expand of a virtual hard disk within the virtual machine, you need
to use the newly available unallocated disk space. Either extend an existing volume or
create a new volume in the unallocated space by using the Disk Management MMC
snap-in or PowerShell. If a shrink was performed, no actions are required; there will
simply be less or no unallocated space on the disk.


To resize using PowerShell, utilize the Resize-VHD cmdlet. You pass the new size by
using the -SizeBytes parameter. (However, you do not have to type the size in bytes;
you can type numbers such as 2GB or 10TB.) The new size can be less or more than
the current size, as long as it is a valid size (not smaller than the MinimumSize
attribute, and not larger than the VHDX 64TB limit or than is physically available if it
is a fixed-size VHDX file). If you want to shrink the file as much as possible, instead of
using -SizeBytes, use the -ToMinimumSize parameter, as in this example:


Resize-VHD .\win81nondomain.vhdx -ToMinimumSize

Free download pdf