4

We have a production server that is used 24/7, running inside Hyper-v. The guest OS is Server 2008 R2. It has a dynamically expanding VHDX and is very close to reaching the maximum size. Is it possible to shrink it without any downtime?

I have seen recommendations of using sdelete -z but one of the problems is the physical drive that the VHDX resides on has a capacity of 1.79TB (52.1 GB Free as of now) and the max size of the VHDX shows 1.82TB, so I don't know if using sdelete will cause the VM to fail/pause if it tries to make the VHDX larger than the physical drive?

If shrinking it without downtime is not possible, is there a way to prevent the VHDX from growing any larger (the guest OS shows 639GB of free space) and just use the existing allocated space? Any help would be greatly appreciated.

JBL
  • 43
  • 5
  • 3
    Can you simply resize the volume/filesystem inside your guest so that it won't actually have any more free space? – Zoredache Dec 27 '17 at 22:13
  • You may find https://technet.microsoft.com/en-us/library/cc731894(v=ws.11).aspx useful on how to shrink the volume in the guest OS. I would then hope hyper-v offers some way to shrink the vhdx after you've shrunk the guest disk some and freed up the end of the disk. – BeowulfNode42 Dec 28 '17 at 00:31
  • `1.` Shrink the Windows volume in the guest OS. `2.` Compact the VHDX. `3.` Shrink the VHDX. – joeqwerty Dec 28 '17 at 02:49
  • Thanks for the replies. I don't want to lose all of that free space, but I think it is a good idea to shrink the volume enough so that the maximum size of the VHDX is not greater than the space on the physical disk. Does anyone see any issues with shrinking a volume on a production server? The volume that I am shrinking does NOT have the OS but is used for various data and stuff. – JBL Dec 28 '17 at 19:51

1 Answers1

4

Is it possible to reclaim unused space on Server 2008r2 VM without downtime?

From my experience, this type of operations (should) require the VM downtime to make things right. Here are steps how to claim more space:

  1. Make sure the VHD is setup as dynamically expanding VHD
  2. Make sure the OS partition does not have shadow copies configured
  3. Power off VM
  4. Attach the VM's VHD to another VM
  5. Run compact

Source: https://community.spiceworks.com/topic/291021-reclaim-unallocated-disk-space-from-vm-on-hyper-v

Mr. Raspberry
  • 3,878
  • 12
  • 32