Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running a number of Hyper-V guest instances. One recommendation to improve the performance of our guest OSes is to defragment the vhd files. Can I do this while the guest is still running? Is there a way to defragment only a single file?

share|improve this question
I found the (formerly) SysInternals Contig utility to defragment single files. It dosn't seem to work with open files. But I still have a question about the Windows Defragment utility in Server 2008. – Eric Falsken Oct 23 '10 at 16:25
up vote 1 down vote accepted

There is a way to defragment only a single file - Contig from SysInternals:

I don't know that you can do it while the files are in use, I'd guess not but am willing to be surprised.

But I'm a bit skeptical that it will do much good unless they are severely fragmented (contig will tell you how many fragments they are in) - especially if you're using modern hard disks which abstract away where they are writing so they can rewrite to avoid errors, a RAID disk system with a controller that has disk cache, with OS disk cache.

And the files within the virtual machines can be fragmented as well so it wont be accessing contiguous parts of the VHD necessarily. And if Hyper-V is anything like VMWare, it has it's own disk handling which merged multiple reads/writes from the VMs into fewer read/writes for the real disks.

Summary: don't expect miraculous speedups unless you've been adding and removing different size virtual machines over and over for ages.

share|improve this answer
Defragmenting a VHD is also quite effective if you've been making use of snapshots and have recently merged the changes. – Eric Falsken Oct 23 '10 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.