How to Resize Virtual Hard Disk on the Running Virtual Machine

0
8865

Shrinking or Expanding the Virtual Hard Disks is a common task for the System administrator. In this article, we will expand the Virtual Disks on the running Hyper-V Virtual Machine. Resizing the Virtual Hard Disks on the Hyper-V can be done through GUI or PowerShell command.

Limitation

There are some limitations to resize the Virtual Hard Disk on the running Hyper-V VM. 

  • There is no virtual machine checkpoint 
    If there is a virtual machine checkpoint created, you need to merge or remove the VM checkpoint first.
  • Only VHDX files that can be expanded on the running Virtual Machine.
    The VHDX disk type is Virtual Hard Disks format on the Windows 2012 and later.
  • The VHDX is attached to the iSCSI controller on the Virtual Machine.
    If the VHD or VHDX is attached to the IDE controller, you need to turn off the Virtual Machine first.

Resize a Virtual Hard Disk with Hyper-V Manager

Hyper-V Manager allows you to resize a virtual hard disk whether or not a virtual machine owns it.

From the Hyper-V Manager, Select the Virtual Machine and click the VM Setting on the right panel

vm setting

Locate the disk that you want to expand and click edit.

Edit Disk

On the Edit Virtual Hard Disk Wizard screen as below, click next.

Virtual Hard Disk Wizard

Select expand and click next.

Select Expand

Enter the value of the new size of VHDX. the new size should be greater than the current size.

Enter New Size

Review your setting and click finish.

Summary

Once the virtual hard disk has been resized, you need to login to the VM to expand the partition. To expand the disk partition, open the Disk management or you can run diskmgmt.msc from the command prompt.

Open Disk Management

On the Disk Management, make sure the unallocated size is available on for the partition.

Unallocated Space

On the volume that you want to extend, right click and select “Extend Volume”. Please note, you can’t extend the volume that isn’t in order partition. 

Extend Volume

Select the available disk and size that you want to add to the existing volume.

Enter Disk Space

Review the changes.

Review

Resize a Virtual Hard Disk with PowerShell

You can also use Resize-VHD PowerShell command to expand the virtual disks. Below is the example command to expand the Virtual Hard Disks.

First, you need to get on which controller the Virtual Hard Disk that you want to expand is attached.

Get-VM -VMName "ANGGA-DC1" | Get-VMHardDiskDrive
Get disk Controller number

After you get the “Controller Number” you can run the command below to expand the Virtual Hard Disks.

Get-VM -VMName "ANGGA-DC1" | Get-VMHardDiskDrive -ControllerNumber 0 | Resize-VHD -SizeBytes 100GB

Note:  you still need to login to the guest operating system to expand the volume from unallocated space.

We hope this article helped you learn How to Resize Virtual Hard Disk on the Running Virtual Machine. If you liked this article, then please share with the others. You can also find us on Twitter and Facebook.

LEAVE A REPLY

Please enter your comment!
Please enter your name here