Expand Virtual Disk Partition Hyper-V Windows Server 2012

Published on: December 16, 2019

This article introduces how to expand/increase disk size in Hyper-V guest Windows Server 2012 (R2) and how to extend virtual partition in hyper-v vm without losing data.

Comparing with physical server, virtual server has many advantages, for example, you'll save much cost if you want to build several servers, because you can achieve with a copy of hardware. Furthermore, you can easily add, edit and remove components. Therefore, many servers are running as guest virtual machine in Hyper-V, VMware or Virtualbox. However, the same with physical hard disk drive, virtual disk partition also runs out of space. This article introduces detailed steps how to extend partition and increase disk size in Windows Server 2012 running as guest virtual machine in Hyper-V.

How to extend partition in Hyper-V guest Windows Server 2012 (R2)

Firstly, you should know that no software can extend partition by taking space from another different disk. When there's free unused space in a partition on the same hard disk, you can shrink it to get Unallocated space and then add to the partition that is full. In this case, there's no difference to extend virtual partition in Hyper-V with physical disk partition.

Before extending partition in Hyper-V virtual Windows Server 2012, you'd better create Checkpoint or make independent backup. While resizing partitions, all parameters of associated disk, partition and files must be modified, sometimes all files in a partition should be moved to new locations, if you want to extend system partition, Windows boot related files must be updated, too. Therefore, there's potential system and data damage risk with unreliable software.

About partitioning tool, the same with previous Server 2008, Windows Server 2012 has two native tools - Disk Management and Diskpart. Disk Management has Extend Volume function with graphical interface, Diskpart has extend command running via command prompt. Although they are running in different way, they have same limitations. For example: only NTFS partition is support, they cannot extend a partition by shrinking any other one. So, to extend virtual partition in Windows Server 2012 (R2) Hyper-V vm, you need 3rd-party software.

There are many partitioning software and the functions are similar, but as I said above, you'd better run the safest tool. Among them all, NIUBI Partition Editor has 1-Second Rollback, Virtual Mode and Cancel-at-will technologies to protect system and data. In addition, it is much faster because of the unique file-moving algorithm.

Download and install NIUBI Partition Editor to Hyper-V virtual machine, you'll see all virtual disk with partition structure on the right. Available operations to selected disk or partition are listed on the left and by right clicking.

NIUBI Partition Editor

As you see in my Hyper-V Windows Server 2012 R2, drive D: and E: are blank, so I can shrink either one to release free unused space, and then add into C: drive.

Steps to extend system partition C in Hyper-V Windows Server 2012 (R2) vm:

  1. Right click the right contiguous drive D: and select "Resize/Move Volume", drag left border towards right in the pop-up window, or directly enter an amount in the box of "Unallocated space before". Then drive D will be shrunk and Unallocated space will be made on its left.

    Shrink D

    Drive D shrunk

  2. Right click C: drive and select "Resize/Move Volume" again, drag right border towards right to combine this Unallocated space. Then partition C will be extended in virtual mode.

    Extend C

    Drive C extended

  3. Click Apply on top left to take effect. (If you did something wrong, simply click Undo to cancel the pending operations.)

It is similar to extend partition C by shrinking the non-adjacent drive E, however, there's an additional step to move Unallocated space next to C drive before merging. Follow the steps in the video to extend Server 2012 system partition in Hyper-V virtual machine:

Video guide

How to expand/increase disk size in Hyper-V Windows Server 2012

In physical server, if a hard disk is getting full, you have to replace it with another larger one. To do this, it costs a long time to copy or restore from backup. But to Hyper-V virtual hard disk, you can expand it to increase disk size fast and easily.

To increase disk size of Hyper-V guest Windows 2012 server, there are two ways with PowerShell or Hyper-V Manager. It is much easier to expand virtual disk with PowerShell.

How to expand hard disk for Hyper-V Windows Server 2012 vm with PowerShell:

  1. Open PowerShell with Administrator privilege from Quick Launch bar, Start menu or other place in your physical computer.
  2. Type Resize-VHD -Path 'D:\hyperv.vhdx' -SizeBytes 200gb

Expand Hyper-V disk

Explanation:

  1. 'D:\hyperv.vhdx' means absolute path and name of the virtual disk with quotes.
  2. 200gb means expanding this virtual hard disk to 200GB, not adding 200GB.

Note: you should delete associated Checkpont(s) and shut down the guest vm first.

Follow the steps if you want to increase virtual disk size for Windows Server 2012 with Hyper-V manager.

How to increase system partition C after expanding Hyper-V vm disk

After expanding virtual hard disk, you'll get additional Unallocated space on the end, then you need to run NIUBI Partition Editor and merge Unallocated space to other partition(s). Follow the steps in the video:

Video guide

Besides shrinking, moving and extending virtual and physical disk partition, NIUBI Partition Editor helps do many other operations.

DOWNLOAD