Microsoft MVP Logo

Do you work with virtual machines? How about over a long period of time? You’ll know that over time, they seem to slow down under heavy use. Why is that? There are plenty of reasons, some are specific to virtual environments, some are more general. This post will focus only on the virtual aspects… general aspects are things like installing tons of beta software, a lot of apps that run in the background or on startup, etc..

The two biggest reasons I see virtual machines get slower over time is due to (1) incorrect virtual machine additions installed and (2) disk fragmentation. If you work with large VHD’s, disk fragmentation becomes your biggest enemy. Seems this is my biggest issue lately working in Office SharePoint Server 2007 beta VPC’s I’ve built… these things are easily 5–15GB depending how you organize your environment.

Some of these topics are covered in my HOWTO: Use Virtual PC’s Differencing Disks to your Advantage article.

Virtual Machine Additions

Make sure you have the latest Virtual Machine Additions loaded. Keep in mind that moving a VHD file from a VirtualPC environment to a Virtual Server environment may result in a sluggish performance… at least I experience that. When I move virtual machines from VPC->VS or vice versa, I always uninstall the virtual machine additions and reinstall the ones for the current environment. It’s my experience that the two (VPC Additions & VS Additions) are not the same and making sure you’re using the one for the current environment can make a world of difference.

Don’t Let Your Disks Get Fragmented!

OK, that’s near impossible. What ~is~ possible is that you can defrag them frequently. What needs to get defragmented? Two things: you virtual disk (the one that your guest OS is installed on) and your physical disk (the one your host OS is installed on). Here’s what I recommend:

Defrag your guest OS disk: Within your virtual machine, run the Windows disk defragmenter three times… yes three times does help. Each time the defragmenter is defragmenting files, it’s moving things around in order to make files more continuous. At the same time, it’s rearranging your disk so the used space is as close to the start of the disk. However, if you only run one pass of the defragmenter, it’s just not going to have enough free space to shuffle the desk and get things in their optimal place. Running it two more times gives the defragmenter enough chances to get things optimally organized. The worst run is always the first… the second and third passes go faster and faster.

Compact your VHD: If you’re using differencing disks, this isn’t an option for you as you can’t compact differencing disks. If you aren’t, then compact it! I explain this process in my HOWTO: Use Virtual PC’s Differencing Disks to your Advantage article, about half-way through… the second paragraph after my “Core Base Disks” image explains how to do this.

Defrag your host OS disk: Once the virtual machine is shut off, run Windows disk defragmenter three times… same reasons I explained in the Defrag your guest OS disk section above.

Make sure your virtual machine’s VHD is not fragmented: Not all files can get defragmented… some are too big to reorganize by the Windows defragmenter. For this, I use CONTIG.EXE from SysInternals. You can use this awesome utility to check how many fragments a file is broken up into or all files in a directory. It will also let you defrag a specific file.

BTW: I finally added two “Virtualization” categories… one for my blog, one for my articles hosted on my blog.

Comments powered by Disqus