One of the new features in Windows Server 2012 R2 and Windows 8.1 is the ability to resize a virtual machines virtual hard disk while it is running. In order to pull this off – all you need is a virtual machine with a .VHDX file attached to a SCSI controller (this functionality is not supported with .VHD files or IDE controllers).
Once you have done this you simply need to open the Edit Virtual Hard Disk wizard. Then you should:
- Locate the virtual hard disk that you want to expand
- Select Expand and click Next
- Enter the new size that you want and click Next
- Click Finish
Once you have done this, we will increase the size of the virtual hard disk. However, we will not do anything with the partitioning on the virtual hard disk. So at this point in time you will have a bunch of extra, unused space at the end of the virtual hard disk. To take advantage of it you will need to login to the guest operating system and do something with it. You can either create a new partition – or extend an existing one. Extending a partition under Windows is simple enough. You just need to:
- Open Disk Management
- Locate the partition that you want to extend
- Right click on it and select Extend Volume
- Select the available space and click Next
- Click Finish
You can also use PowerShell in the parent partition to expand a virtual hard disk, like this:
Get-VM "Windows Server – Resize" | Get-VMHardDiskDrive -ControllerType SCSI | Resize-VHD -SizeBytes 200GB
Note, this is the same command that you use whether the virtual machine is running or not. Also note that you still need to login to the guest operating system to take advantage of the extra space.