Is compacting a Hyper V VHD (Server 2008 R2 Host) a safe operation? I compacted a Server 2008 Std 64 Bit virtual machine's boot volume and it ended up being about 500 Mb smaller. The VM was shut down at the time. However over the next 10 days that machine seemed to lock up in very strange way approximately every 2 days but not a consistent time.

It would stop responding to the network, but it was sometimes possible to get in on the console directly on the Hyper V host. If the console was locked it would not respond to ctrl-alt-delete but the easy access button would hilight and unhilight with a mouse-over. And it could be clicked and the window opened but would not respond to anything else. On one occasion the console was not locked and the start menu could be used, and the right-click menu for icons would pop-up. However there was no response to starting an application, or clicking on menus. It also would not shut-down even from the the Hyper-V manager and had to be powered off and on. After a power off and on it worked normally sometimes for a few days.

There are no useful messages in the Windows errors logs - aside from unexpected shutdown errors. A check disk reported no errors, and aside from the hanging the machine behaved normally.

I have reverted to a copy of the VHD taken before the compact and so far it has not hung (in 3 days).

I want to think this wasn't due to the compact process, however the timing is very suspicious and now I am very wary of using compact. However, I have not been able to find anyone else reporting a problem with it.

And yes this is a relatively unimportant production server, I know most people recommend fixed size VHD for production, but I want to minimize disk usage and don't mind a slight performance penalty.

3 Answers 3


I know its not going to answer your problem, but I have a few VMWare images that get compacted reasonably regularly, and I've never had the problem you describe.

I'd try again and see if you get the same errors, it's possible it was a 'glitch' (but I guess that still doesn't help if you can't trust the operation any more)


It is safe, if you have thoroughly checked the file system for errors first. Compacting just creates a new VHD file and copies all the files over to it. The old file isn't modified at all until the operation is completed (at which time the old file is deleted). The old adage applies though, garbage in means garbage out.

  • I've done numerous compacts since this and not seen this problem again. Nevertheless I am a still a little wary of compact. I haven't done this machine again though, except for a test copy which did not seem to have the problem.
    – IainS
    Nov 15, 2010 at 1:47

As you have already discovered, it is not a safe operation. Any kind of wholesale manipulation of a VHD file falls squarely into the category of "things that should make any administrator pause and think about backups."

Obviously, you were diligent enough to retain a backup copy, and it has served you well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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