Search This Blog

Tuesday, October 28, 2014

Shrink a Hyper-V Virtual Disk Before Upload To Azure

Currently we are busy on migrating an application to Microsoft Azure. Before that, customer has setup their application running on Windows Server 2012 Hyper-V. Most of the VMs are running Windows Server 2012 as the guest operating system and has different size of virtual disk. During the migration we found out we need to do some fix up before upload a virtual disk to Azure. Here is an example of an issue:


A virtual disk consists of 750GB of total size with multiple partition. Before upload a virtual disk to Azure, make sure

  • An operating system should be in 127 GB size
  • Data disk should not more than 1 TB size
  • Virtual disk must be VHD format

We need to split the partition into multiple virtual disk.


Step 1

  • Create a new virtual disk for E and F.
  • Copy content to designated new virtual disk


Step 2

  • Remove the partition from Disk 1


Step 3

  • Convert Disk 2 from vhdx to VHD
  • Convert Disk 3 from vhdx to VHD

By using Hyper-V Manager Console. Use Edit Disk Action

  • For C Drive, use disk management on the operating system to shrink the partition. Before that, remember to defrag first. Shrink it to less than 127GB.


Step 4

  • Turn of the virtual machine
  • Use Hyper-V Manager Console to Shrink the virtual disk. You can only shrink a virtual disk when it is in VHDX format.


It will reclaim the free hard disk space and reduce your virtual disk from 750GB to 120GB.


  • Verify by boot up the VM by using a new virtual disk.
  • If it is working fine, then you can sysprep it and use Hyper-V Manager Console to Convert to VHD (Use Edit Disk action)

That’s all for now and you can start to upload Disk 1, Disk 2 and Disk 3 to Azure.