Windows Server 2012 R2 brought us the ability to resize virtual disks on line. This was a long sought after feature for many of us. It can be done via the GUI or with PowerShell. I do note however that quite often people have some problems when first using this capability. So we’ll go over the rules & prerequisites here.
Listed below are the important factors to keep in mind
- It has to be a VHDX
- Works for both generation 1 and generation 2 virtual machines
- It needs to be attached to a vSCSI controller. Remember this when dealing with with generation 1 virtual machines. In particular note that this means you cannot live resize the system disk as that IDE only (can’t boot from SCSI in generation 1).
- The virtual disk cannot be a shared VDHX (it’s on my feature request list for vNext)
- You can extend a virtual disk
- You can shrink a virtual disk
- This feature can leverage ODX for speed when available. The speed of this is quite addictive.
Some notes where people seem to make some other mistakes
You’ll note that you cannot shrink a virtual disk that has no unallocated disk space on the disk inside the virtual machine. When you see this picture inside of the virtual machines you can shrink your VHDX if all the above factors are in order.
If there is no unallocated disk space the option to shrink the VHDX won’t even show up in the GUI.
This means you’ll first need to shrink the volume inside the virtual machine if all disk space has already been allocated.
(Like wise don’t forget to expand the volume inside the VM to be able to use the added space you see show up as unallocated space on the disk.)
The below image is a great summary of the above
Legacy OS in the VM?
It’s also important to note that an OS inside a VM (Windows Server 2003 comes to mind) that does not allow the expansion or shrinking of volumes means you will need a 3rd party tool to do the same. I use GParted, a free partition editor for these scenarios.