Tag Archives: PowerShell

Live Growing Virtual Disks In HyperV 2012R2

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!

  1. On the HyperV server, start PowerShell (PS) as Administrator
  2. Locate your VHD(X) file.
  3. Assume we want a new size of 20GB, type “Resize-VHD <filename> -SizeBytes 20GB”, hit Enter and relax.
  4. When PS is done the new size will be 20GB. Easy!
  5. Now log on to the guest VM.
  6. Type “Windows+R” and in the Run dialog type “diskmgmt.msc” and hit Enter.
  7. 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.
  8. Right click on the partition and select “Extend Volume…”, Next, Select new size, Next, Finish
  9. Now allow windows to repartition the drive for you, this should go quite fast. And you’re set. Check the new size in explorer.
  10. If you want to, steps 6-9 can be replaced with the new kid on the block, the mighty PowerShell
    1. Start PowerShell as Administrator
    2. Type “Get-Volume”, take note of the driveletter
    3. Setup a variable, Type “$newsize=(Get-PartitionSupportedSize – DriveLetter <DriveLetter>”
    4. OPTIONAL: Check that the variable contains data, Type “write-host $newsize”
    5. Resize partition, Type “Resize-Partition -DriveLetter <DriveLetter> -Size $newsize.sizemax
    6. Type “Get-Volume” and verify size! Done!