Dealing with a VHD that grew too large


Q: Lach writes with this question: “I have 2 virtual machines installed, and had them set up as dynamic hard drives [dynamically expanding VHDs]. One has gotten to 16 gb, and has all but filled up my hard drive. I would like to make it smaller, as the hard drive is only 1/2 used. Any advice?”


A: Lach, you need to compact your VHD. First, delete as much unneeded data as possible from the VHD and defragment the hard disk. Then follow the instructions in “Compacting a dynamically expanding virtual hard disk” in the Virtual Server 2005 Administrator’s Guide. As mentioned in this topic, you must precompact the VHD before you can compact it. A Microsoft tool, the Virtual Disk Precompactor, is now available for this purpose. For more information, see http://blogs.technet.com/megand/archive/2004/12/10/279808.aspx.


Another thing you can do when a VHD outgrows a physical disk is to move the VHD to a different physical disk that has more space. When you do this, you must first remove the VHD from your virtual machine, move it, and then add back to the virtual machine from the new location. In addition, if the physical disk is not located on the same physical computer as the virtual machine, you’ll need to do some additional configuration. For more information, see http://blogs.technet.com/megand/archive/1005/05/11/404846.aspx.


For future reference, remember to specify the maximum size to which you want your dynamically expanding VHDs to grow when you create them. The default size is 16 GB.


Note: I just read a blog post by Guoqiang Wu that recommends using a defragmenting tool created by Dave Whitney rather than the one included with Windows. For more info on the tool, go to http://blogs.msdn.com/guowu/archive/2005/05/17/418457.aspx.

Comments (3)

  1. Anonymous says:

    I blog about Virtual Server a lot (as you may have noticed), but I’m not alone. Megan Davis is a…

  2. Anonymous says:

    Using Virtual PC for computer migration

    Tips for migrating a physical computer to a virtual machine:…