Sdílet prostřednictvím


Shrinking a virtual hard disk in Windows 8

Late last year I posted about the process that I followed to reduce the disk size of my virtual machines, prior to converting them to using a fixed size virtual hard disk.  The process I used was quite complicated.

If only I had waited for the beta availability of Windows Server 2012 – things could have been a lot simpler.  You see, one of the new features in Windows Server 2012 is the ability to shrink a virtual hard disk.  You need to free up space inside the virtual hard disk first – but then you can shrink the drive using a simple wizard.  This means that the process of shrinking an existing virtual machine now looks like this:

 

  1. Login to the virtual machine using an administrative account
  2. Open Server Manager and select the Disk Management node under the Storage node.
  3. Right click on the partition that you want to shrink and select Shrink
  4. Select how much you want to shrink the partition by
    1. In my case I want to shrink a 250GB partition to 70GB:
      Server Manager inside a virtual machine
  5. Once this is complete, shutdown the virtual machine.
  6. Open the virtual machine settings under Hyper-V and select the virtual hard disk that you want to shrink.
  7. Click on the Edit button.
  8. This will open the Edit Virtual Hard Disk Wizard where you can now select to Shrink the virtual hard disk:
    Edit Virtual Hard disk Wizard 
  9. Now hit Finish

Hyper-V will automatically shrink the virtual hard disk to remove any free space from the end of the disk – so there is no need to enter how much you want to shrink the disk by.  Once this process is complete your can boot the virtual machine and start using the smaller virtual hard disks.

Cheers,
Ben

Comments

  • Anonymous
    May 07, 2012
    Nice! :) Is this only in Server or client too?

  • Anonymous
    May 07, 2012
    It is in client too

  • Anonymous
    May 08, 2012
    Hello Ben, Finally i see the shrink option. If a VHD is 300 GB , with shrink , can we make 40 GB? Means i made a P2V operation and i can make smaller vhd after P2V? If yes , you are 5 star person :)For 2 years i am waiting for this. Murat Demirkiran

  • Anonymous
    May 09, 2012
    Murat - Yes, this is correct :)

  • Anonymous
    May 09, 2012
    Assuming I'm not doing it incorrectly it only works with vhdx disks. This would make sense - it's just worth pointing out :) It seems it will work doing the partition shrink when running on a vhd, then shut down the vm, convert vhd->vhdx and then do the shrink in the Hyper-V console. (And remember to change the vm properties to use the new vhdx file.)

  • Anonymous
    May 13, 2012
    Hi, I have done it with Powershell vniklas.djungeln.se/.../shrink-hyperv-virtual-hard-disk-win8-win2012-with-powershell regards Niklas

  • Anonymous
    September 24, 2012
    Hi Ben, Thanks for this new feature!  Any chance SHRINK will be added to Hyper-V 2008 R2?  Or at least a separate tool that's supported from MS? Josh

  • Anonymous
    January 26, 2015
    Good for just shrinking partition too, I was trying to also decrease the VHD size allocated to the virtual machines disk, the additional steps can be found here on how to shrink that too www.rootusers.com/decreasing-disk-space-in-windows-server-2012-r2