Online Resizing Of Hyper-V Virtual Disks Is Possible in Windows 2012 R2

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

  1. It has to be a VHDX
  2. Works for both generation 1 and generation 2 virtual machines
  3. 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).
  4. The virtual disk cannot be a shared VDHX (it’s on my feature request list for vNext)
  5. You can extend a virtual disk
  6. You can shrink a virtual disk
  7. 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.image

image

If there is no unallocated disk space the option to shrink the VHDX won’t even show up in the GUI.

image

This means you’ll first need to shrink the volume inside the virtual machine if all disk space has already been allocated.

image

(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

image

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.

ODX Doesn’t Support IDE But Works With Both VHDX And VHD Virtual Disk Format

This question came up recently, once again, and deserves it a little blog post. If you want to see the benefits of ODX you’ll need to connect your virtual disks to a vSCSI controller or other supported controller option. These are iSCSI, vFC, a SMB 3 File Share or a pass-through disk. But unless you have really good reason to use pass-through disks, don’t. It’s limiting you in to many ways.

Basically in generation 1 virtual machines that boot from a vIDE this rules out the system disk. So the tip here is to store your data that’s moved around in or between virtual machines in vSCSI attached VDH or (preferably) VHDX  virtual disks. If you can use generation 2 virtual machines, you’ll be able to leveraged ODX on the system partition as well as it boots from vSCSI Smile.

It goes without saying you need to store any virtual disks  involved on ODX capable LUNs via iSCSI, FC, FCoE, SMB 3 File Share or SAS for ODX to be available to the virtual machine.

Also beware that ODX only works on NTFS partitioned disks. The files cannot be compressed or encrypted.  Sparse files are not supported either. And finally, the volume cannot be BitLocker protected.

Here’s a screenshot of a copy of 30GB worth of ISO files to a VHDX attached to a vSCSI controller:image

Here’s a screenshot of a copy of 30GB worth of ISO files to a VHDX attached to a vIDE controller.

image

You’ll notice quite a difference. Depending on the load on the controllers/SAN it’s on average 3 times slower than the same action to a VHDX disk on a vSCSI controller.