This is a new feature instroduced in HyperV 2012R2. Previous to R2 the virtual machine had to be shutdown prior to resizing the VHDX file (VHD does NOT support this). Quite a hassle if you are a non-stop-shop! The process is a little different if you need to Grow or Shrink the volumes but i’ll step you all the way through!
Lets start by Live Growing the disk!
- On the HyperV server, start PowerShell (PS) as Administrator
- Locate your VHD(X) file.
- Assume we want a new size of 20GB, type “Resize-VHD <filename> -SizeBytes 20GB”, hit Enter and relax.
- When PS is done the new size will be 20GB. Easy!
- Now log on to the guest VM.
- Type “Windows+R” and in the Run dialog type “diskmgmt.msc” and hit Enter.
- In Disk Management locate the disk to Grow and note that there should be some “white” space available to the right side of the bar.
- Right click on the partition and select “Extend Volume…”, Next, Select new size, Next, Finish
- Now allow windows to repartition the drive for you, this should go quite fast. And you’re set. Check the new size in explorer.
- If you want to, steps 6-9 can be replaced with the new kid on the block, the mighty PowerShell
- Start PowerShell as Administrator
- Type “Get-Volume”, take note of the driveletter
- Setup a variable, Type “$newsize=(Get-PartitionSupportedSize – DriveLetter <DriveLetter>”
- OPTIONAL: Check that the variable contains data, Type “write-host $newsize”
- Resize partition, Type “Resize-Partition -DriveLetter <DriveLetter> -Size $newsize.sizemax
- Type “Get-Volume” and verify size! Done!