Windows Server TechCenter > Windows Server Forums > Windows Server 2008 R2 Hyper-V > Server 2008 R2 Hyper-V Defragmentation Best Practices
Ask a questionAsk a question
 

AnswerServer 2008 R2 Hyper-V Defragmentation Best Practices

  • Monday, August 31, 2009 5:27 PMRichard Raseley Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello.

    I am looking to see if anyone has any guidance on best practices for defragmenting Hyper-V servers running Server 2008 R2 Datacenter. Should I use the built in defragmentation program? Can I defrag the array that is holding all my VHD files while the VMs are running?

    Any guidance on this issue would be appreciated.

Answers

All Replies

  • Tuesday, September 01, 2009 5:28 AMozan veranyurt Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It is a good idea to do the defragmentation of the host disk before creating vhds. You can turn VMs down then run defrag.exe that is built in for the host disk and run the defrag seperately for each virtual machine.

    Hope that helps

    Ozan Veranyurt MCITP-MCT http://hyperv.virtualozzy.com (Your step to Virtualization) Please mark as an answer if you feel it is.
  • Tuesday, September 01, 2009 7:51 AMVincent HuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

     

    If using Fixed Disks, Host-based defragmentation is not needed because the entire VHD is pre-allocated in a contiguous fashion. Guest-based defragmentation would be not different than it is with physical, the built-in utility works fine. However, it may be a useful tool if Dynamically Expanding disks, Differencing disks, or Snapshots are regularly used.

     

    In addition, if you want to do a defragment in Hyper-V host computer, it’s better to turn off the VMs.

     

    For more information, you can refer to:

     

    Performance Tuning Guidelines for Windows Server 2008

    http://www.microsoft.com/whdc/system/sysperf/Perf_tun_srv.mspx

     

     

    Best Regards,

    Vincent Hu

  • Tuesday, September 01, 2009 4:59 PMVictor Lindsey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    If using Fixed Disks, Host-based defragmentation is not needed because the entire VHD is pre-allocated in a contiguous fashion...


    One technique I find useful, is to defrag a child partition's fixed-size VHD volume by mounting it with VHDMOUNT.vbs to the parent partition (a.k.a. host or root partition), then run defrag explicitly to that volume, then dismount it.  This permits an "offline" degragmentation, the best kind in my opinion.

    There are various source on the Internet for this mount utility.  One source is http://code.msdn.microsoft.com/VHDShellExt, but there are others that work too.

    New with Windows Server 2008 R2, is the Disk Management console snap-in (diskmgmt.msc) capability to mount/dismount a VHD for you to/from the parent partition.  Just start from the Action menu item and work your way down.

    Happy defrag!

    Vic
    • Edited byVictor Lindsey Wednesday, September 02, 2009 4:22 PM- update regarding new R2 feature
    •