Online VHDX Resize in Windows Server 2012 R2 / Windows 8.1
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.
Cheers,
Ben
Comments
Anonymous
January 28, 2014
Ben, shrinking is not possible in this way? The virtual machine has to be turned off?Anonymous
April 05, 2014
The comment has been removedAnonymous
July 23, 2015
Thanks so much. This is the only article (that I found so far, and I searched...) that mention to use the Disk Management in the guest O.S to claim this new space, otherwise the current file size capacity stays the same.Anonymous
March 07, 2017
There's no need to login to the guest OS, just typeGet-Volume E -cimsession GuestHostname | Resize-Partition -size (200gb)Anonymous
August 18, 2017
The comment has been removed