Hyper-V WindowsServer 2012 R2 came up with a new function Online VHDX Resize that allows dynamic VHDX resizing of the working virtual machine (i.e. online). Online VHDX Resize allows both to extend and to compact a virtual disk. In this article we’ll deal with the features of this technology and its limitations.
[tab title=”Contents of this article”]
Common Features of Online VHDX Resize
- It is possible to change the disk size (including the system disk of the guest OS) on-wire with no need to turn off the virtual machine.
- Online VHDX Resize works both on the first and the second generation of virtual machines Hyper-V.
- Both Windows and Linux can act as a guest OS.
- Both extension and shrinking of virtual disks are supported.
Requirements and Limitations of OnlineVHDXResize Function
First of all, we’ll consider the requirements to be observed to successfully resize the virtual disk on-the-fly.
- Only VHDXs can be dynamically resized. VHDs are not supported and have to be converted into the VHDX format (How to convert VHD into VHDX in Windows Server 2012)
- VHDX to be resized should be mounted to the virtual SCSI controller (not the IDE)
- Resizing of shared VHDX files used in the cluster is not supported
- Snapshots of the virtual machine do not allow VHDX resizing
How to Extend VHDX in Windows Server 2012 R2
Let’s describe the procedure of VHDX extension in detail.
- Choose the virtual machine in the virtual machine manager Hyper-V and go to its settings (Settings).
- Choose the virtual disk and click the Edit button.
- In the appearing wizard choose Expand
- Specify the new size of the virtual hard disk (in our example we’ll expand the disk size to 170 GB).
- Then click Finish.
- Go to the console of the guest OS, which disk was extended. Open the console of the Disk Manager. As you can see, extra 42 GB of unallocated space appeared in the system.
- Right-click the partition you want to extend and choose Extend Volume, then specify the size of its extension due to the unallocated space.
- After completing the Extend procedure, the disk size will be increased.
How to Shrink VHDX in Hyper-V 2012 R2
Let’s move on to the description of the VHDX shrinking.
- Before shrinking the virtual disk, you should «cut a piece» from one of the volumes, thus making some space unallocated. To do it, open the Disk Manager of the guest OS, select a volume and click Shrink Volume.Note. Shrink Volume becomes available only if there is some free space on the disk.
- Specify the amount of space to shrink the partition by (in our example we specified 50GB).
- After the partition of the guest OS has been shrunk, go to the settings in the Hyper-V console and click the Edit button again.
- Click Shrink in the wizard and specify the amount of space to shrink the VHDX file.
VHDX Resizing with Powershell
You can also change the size of the VHDX in Powershell with the cmdlet Resize-VirtualDisk. It looks as follows:
Resize-VirtualDisk -FriendlyName "ISCSIVHD1" -Size (30GB)
You can change the size of the file system in the guest OS partition using the command:
resize-partition -driveletter C -size (30GB)