I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

July 19, 2006

Creating Smaller Virtual Machines

Now that Virtual PC is finally free, I've become obsessed with producing the smallest possible Windows XP Virtual PC image. It's quite a challenge, because a default XP install can eat up well over a gigabyte. Once you factor in the swapfile and other overhead, you're generally talking about around 2-4 gigabytes for relatively simple configurations.

My best result so far, however, is a 641 megabyte virtual machine image of a clean, fully patched Windows XP install. Not bad. And here's how I did it.

First, start with the obvious stuff:

  1. Install Windows XP SP2. Take all default options.
  2. Connect to Windows update; install all critical updates.
  3. Install VM additions.
  4. Turn off system restore.
    • Right click My Computer; select properties
    • Click the System Restore tab
    • Click the "Turn off System Restore" checkbox
    • OK all the way back out
  5. Set Visual Effects to minimum.
    • Right click My Computer; select Properties
    • Click the Advanced tab
    • Click the Performance Settings button
    • Click the "Adjust for best performance" checkbox
    • OK all the way back out.
  6. Shut down.

Don't install anything else yet! Remember, we're trying to get to a minimal baseline install of Windows XP first. A nice, flat platform to build on.

It's critical to turn off system restore, because that eats up hundreds of megabytes of disk space. In a virtual machine environment, having a rollback path doesn't make sense anyway. And if the Windows software environment wasn't so pathological, we wouldn't need complex rollback support embedded in the OS, either, but I digress.

Now let's put together our toolkit of virtual machine optimization:

Thes utilities are mostly free. And, except for Crap Cleaner, they don't even require installers. Just plop all the files for each one into a folder; I call mine VM-utils. Copy this folder to the target VM.

  1. Use TweakUI to turn on automatic login. Otherwise you have to distribute login credentials with your VM, and who wants to do that?

  2. Now, use XPlite to tear out all the annoying, unnecessary bits of Windows XP:

    XPlite Screenshot

    XPlite is easily the best utility of its type; it removes scads of useless things built into XP that have no explicit uninstall mechanism. Unfortunately, XPlite is payware. There is a free version, but it's crippled; it can only remove a fraction of the items the full version can. See the full list of items it can remove along the right-hand side of the product page.

    By default, XPlite generally shows things that are safe to remove. Note that the "Advanced Components" item is shown in that screenshot, which is definitely stuff that's not safe to remove unless you really know what you're doing. Anyway, here's what I consider totally safe to remove in XPlite's standard list:

    • Accessibility Options
    • Communication and Messaging
    • Server Components
    • Games
    • System Services

    The others require a bit of judicious selection.

    • Accessories - you probably want Notepad, Calc, and the other essential applets. A world without Notepad is a world I don't want to live in.
    • Internet Utilities - if you want to keep the default IE6 inside XP, I'd leave this alone. With the notable exception of MSN Explorer, which is always safe to drop.
    • Multimedia - if you have sound enabled, selectively keep some of this, otherwise dump it all. It's highly unlikely you would ever want to watch videos or listen to music inside your VM, right? Right?
    • Operating System Options - you may want to keep the core fonts if you're planning to browse the web within the VM. Also, beware of removing the service pack update files. Most of this is safe to dump, though. However, you will need the VB6 runtimes for Crap Cleaner to run!
    • System Tools & Utilities - I'd leave Dr. Watson, and possibly PerfMon, WSH and Zip folder support.

    Once you've made your selections, let XPlite do its thing. It's worth the effort, because you'll have an unbelievably squeaky clean Start menu when it's done. Who knew Windows XP could be this.. simple?

  3. Install and run Crap Cleaner. Perform the default analysis, then do a cleanup. This step is really optional; it only cleans up a couple megabytes of log files and miscellaneous junk. Be sure to uninstall Crap Cleaner when you're done, too.

  4. Now that we've cleaned everything up, we need to defragment the disk.

    whitney defragmenter screenshot

    You can use any defragmenter you like, of course, but this one is free and works quite well.

    1. Navigate to the folder where you put your VM utilities, including the Whitney Defragger.
    2. Open a command prompt
    3. Copy the defragmenting program to our windows system folder:

      copy bootdfrg.exe c:windowssystem32

    4. Install the defragmenting service:

      defrag -i

    5. Schedule a defragmentation of the c: drive for the next boot:

      defrag -d c: -B

    6. Restart the virtual machine.
    7. The defragmenter will run before Windows loads. Let it run to completion. It may take a little while, but it provides lots of textual feedback on what it's doing.

  5. Now we have to zero the free space on the drive. You have your choice of the free Microsoft Virtual PC Pre-Compactor, or the inexpensive Invirtus VM Optimizer. Both do the same thing, but the Invirtus tool results in an image that's about 15 percent smaller (641 megabytes vs. 758 megabytes, in my test) than the Microsoft tool.

    Either way, you're mounting an ISO. The Microsoft Pre-Compactor is in a folder named "Virtual Machine Additions" under your Virtual PC install folder. Once mounted, the precompactor will autorun. Let it prep the drive; this doesn't take long.

    Cleanly shut down the virtual machine.

  6. Finally, shrink the virtual machine hard drive using the disk wizard available from the Virtual PC UI:

    1. Click the File | Virtual Disk Wizard drop-down menu
    2. Edit an existing virtual disk
    3. Select the correct disk image
    4. Select "Compact it"
    5. Select "replacing the original file"

    .. and prepare to marvel at the tiny size* of the resulting hard drive image!

It's really quite amazing how snappy and compact Windows XP can be, once you remove all the useless cruft from it.

* that's what she said.

Posted by Jeff Atwood    View blog reactions
« Why Can't Database Tables Index Themselves?
I Pity The Fool Who Doesn't Write Unit Tests »

The resulting 758 megabyte .vhd (Virtual Hard Drive) image is also highly compressible.

I created a self-extracting RAR image of the .vhd and the .vmc file -- it's only *243* megabytes!

Really cool!

Jeff Atwood on July 20, 2006 11:19 AM

Have you tried running VMOptimizer on the final image, to see if you can squeeze it down a bit more?


Kevin Dente on July 20, 2006 11:37 AM

This is del.icio.us material! What a cool concept that you can distribute a full VM on a single CD-R!

Since my laptop doesn't have a DVD Burner, I struggled with this.

However, as soon as you install Visual Studio / Sharepoint / SQL Server, and such it will push it over the 800mb limit, but at least you can have a CD of something to start with.

Good work.

Ben Scheirman on July 20, 2006 11:39 AM

You may want to look at the free nLite tool to create a stripped-down Windows XP CD. It appears to include some of the same functionality as XPlite, but applies it before the OS is installed.


Alex Tsang on July 20, 2006 11:50 AM

Nlite's great for creating very stripped-down disc images to install from. It provides cleaning options very similar to XpLite and is free.

Pat cavit on July 20, 2006 12:05 PM

it would be nice to have a heavily trimmed down windows xp install entirely geared towards gaming

for us linux and mac users to install on another partition

oldman on July 20, 2006 12:09 PM

Compress it with 7-Zip instead of RAR, and you'll save even more space.


It's free (LGPL).

C-J Berg on July 20, 2006 12:43 PM

> Have you tried running VMOptimizer on the final image

I was skeptical, but VMOptimizer worked. You use their special ISO to compact instead of the buil in Pre-Compaction ISO. Here's what I got...

Original size: 758 megabytes
VMOptimizer size: 641 megabytes

Jeff Atwood on July 20, 2006 12:44 PM

Did you turn off hibernation support? hiberfil.sys is a big as the VM's ram.

Leonel on July 20, 2006 01:58 PM

I have an XP boot CD made using...something (I forget what), so that's obviously a very small build.

[ICR] on July 20, 2006 02:04 PM

"Unfortunately, XPlite is payware"

Why is paying for a good product an issue? Don't you
like to get paid for the develpment work you do?

Like many out there I like open source and free whenever it makes since but clearly you liked the product and shouldn't the developer or team that created be rewarded.

VHF on July 20, 2006 02:12 PM

> hiberfil.sys is a big as the VM's ram.

Hibernation is generally off by default in XP.. I always have to manually enable it.

> Why is paying for a good product an issue?

It's not an issue. In fact I bought a copy of XPlite during the composition of this post. But one of these things is not like the other..

Jeff Atwood on July 20, 2006 02:22 PM

I'll second the VMOptimizer recommendation. It saves tons of time, does a great job, and it's a very inexpensive. One of the few pieces of software I was happy to buy.

And 7-Zip's worth it when you get to files that size. I wrote up some info on it before here:
I think one of the switch names may have changed in newer 7-Zip releases.

True, a lot of people don't have 7-Zip installed, but it's really easy to make an SFX (self-extracting zip), so you distribute an EXE file which unzips itself.

Jon Galloway on July 20, 2006 03:01 PM

Great post, but seriously, I'm amazed you'd waste this kind of time and not just use Virtual Optimizer.


On my post you said this functionality wasn't worth $40. You MUST have spent at least an hour messing with this and writing this post. How much are you paid an hour? ;)

Scott Hanselman on July 20, 2006 05:16 PM

And another thing...no way I'm installing a defrager made by the "Whitney Family." Who do you trust?

pagedfrg by SysInternals:


Scott Hanselman on July 20, 2006 05:18 PM

> I'm amazed you'd waste this kind of time and not just use Virtual Optimizer.

The Virtual Optimizer only zeroes out the drive. it doesn't..

1) Reduce the size of Windows XP
2) Defragment the drive

It does provide a 15% size reduction, which is nice, but it's hardly the entire point of the article. It does work as advertised, but personally, I'd rather spend that $40 on XPlite.

> no way I'm installing a defrager made by the "Whitney Family." Who do you trust?

Yes, it might destroy my.. virtual.. machine.. oh no. ;)

Jeff Atwood on July 20, 2006 09:51 PM

There was a big thread at neowin.net's forum where some guys tried to have the smallest windows folder. One of those guys wrote a complete guide which you can read at http://www.bold-fortune.com/forums/index.php?showtopic=229

Everything is done manually

FlorentG on July 21, 2006 12:57 AM

I wonder if Parallels' compressor (trialware) would compress any better than Invirtus VM Optimizer or Virtual PC?

George on July 21, 2006 02:15 AM

Why free matters: I'm allowed to use free utilities at work, but anything I have to pay for requires a lot of red tape. It is actually easier to get a $600 tool than say a $40 tool.

rsbohn on July 21, 2006 05:18 AM

I assume you did this, but not specifically mentioned:

Go into the Windows directory and delete all the patch backup directories, these can easily add up to > 50MB space on disk.

Richard on July 21, 2006 06:55 AM


Have you also gotten rid of all of the driver cab files. Your hardware is a known issue, so you shouldn't need any of the autodetect hardware stuff. I believe it is "%windows%/driver cache." In the past when Connectix owned it, I would even minimize the size of the swapfile. With 2GB RAM, my VM's are hardly noticable during demos.

I must say though, if anyone reading this is going to do presentations with VM's--don't say..."It's the VMs fault"--it's your fault if you haven't prepared a correctly working VM (including plenty of RAM to go with it)! It's like Hanselman's comment on "I know you can't read this, but..." See hanselman.com/tools for ways to fix that too.

Brian Sherwin on July 21, 2006 07:18 AM


I thought you might be interested in this thread concerning the so called "TinyXP" build that is claimed to be sub 70 MB in size.

<a href="http://www.xtremesystems.org/forums/showthread.php?t=84885">http://www.xtremesystems.org/forums/showthread.php?t=84885</a>;

I haven't personally verified claims, so i will be very interested in the results if you choose to test it.

Here's another idea - how come we don't see VM image freely distributed over Bit-Torrent and such? I mean as far as i understand - if the system is Sysprep'ed prior to distribution - it will require license key and in many ways will be indentical to a regular install, so that doesn't necessarily equate to piracy. At least that's not my intention bringing it up.

Fine, maybe Microsoft can be opposed to 3rd party distribution for one reason or another - but they themselves could defenitely distribute beta versions of their products in such form, no?

Vlad Ivanov on July 21, 2006 07:35 AM

I am sorry, i had the link in my bookmarks for a while, so my memory of the contents was a little bit hazy - i just visited the link again prompted by your post and i'd like to make a correction:

It's a 100MB install that results in a 400MB installed image, that is claimed to only use 40MB of RAM to run.

Seems like still an improvement over your results.

Vlad Ivanov on July 21, 2006 07:42 AM

You should change your path from:





Omar Shahine on July 21, 2006 08:40 AM

> Have you also gotten rid of all of the driver cab files. Your hardware is a known issue, so you shouldn't need any of the autodetect hardware stuff. I believe it is "%windows%/driver cache."

Good idea. I ticked those two boxes in XPlite (remove cached server pack files, remove cached driver files). I tried to run Invirtus again, but it refused -- "can only run one time per VM for trial edition". Instead, I ran the invirtus drive zero-ing command line tool ( InvirtusFreeSpace.exe ) that's on the Invirtus trial ISO image. That produced the same compaction results as doing an autorun (!)

The resulting image is now 587 megabytes.

Jeff Atwood on July 21, 2006 10:18 AM

Does all this work with virtual server too, or this a vpc thing only?

Malcolm Anderson on July 21, 2006 03:20 PM

Here's an easy one:

Still not using that good old modem and are not planning to in the foreseeable future? Got a xDSL line, Wifi connection or LAN you always hook up to?

I thought so...

Then why not kill all the modem driver description files from "%systemroot%\inf"? They're the "mdm*.inf" ones and they take up quite a few megabytes.

Btw.: Does anyone know a simple way to locate other deletable driver files... like say: old ISA-card drivers, drivers from obsolete graphic cards and TV-tuner devices?

Henrik Spuur Hansen on July 21, 2006 05:56 PM

this post is a keeper!

(lb tucks the entry away in his del.icio.us account)

lb on July 23, 2006 03:13 AM

You can also delete %WINDIR%\$NtUninstall--------$ folders: I am assuming that you would keep a backup of 'original' virtual image somewhere safe (like DVD or CD), and these folders can run up to several hundred MB..

I would also reduce/disable trash bin size and space your browser allocates for disk cache.

Maksim Pavlishin on July 24, 2006 11:55 AM

Has anyone had any luck with Win2k3? I can only get to about 1.5 GB with SQL Server and IIS.

dave on July 31, 2006 01:37 PM

Another interesting idea: once the "base" drive image is created you can switch the virtualPC machine to use a differential drive based on the "base" drive. This differential drive can be kept in sync using FolderShare so you can use the same Virtual machine from different computers without many synchronization troubles.

Paperino on July 31, 2006 03:47 PM

Sounds great - no good for test machines where you need it to be a pure 'out-of-the-box' self-resetting VM, but just the ticket for specialist needs, such as setting up a Subversion server, or creating a sandboxed Internet browser VM.

Hmm - your filter is now blocking (dot)info web addresses as 'questionable content'.

Paul Coddington on August 1, 2006 05:58 AM

Just shrunk my Win2k3 base drive to < 1GB using the methods outlined here and the Invirtus optimizer.


Bryant Likes on August 22, 2006 05:16 PM

We've got a 14Mb XP iso booting cmd.exe as shell and a standard project that will create a 50Mb XP boot CD with explorer as shell (not to mention a few other features like the hability to boot and run from RAM)

This is done using WinBuilder and the projects that come included with it. All our works and developments are free to everyone.

Nuno Brito on August 25, 2006 04:27 AM

hey, just randomly came across this when searching for something else... just goign to say, i run TinyXP and it does what it says, i'm using it as a main OS though as my windows xp was broken and i didnt realise when i formatted my pc... but tinyxp does use 40mb of ram and around about 400mb installed... it's a great OS.

lonewolfxix on September 13, 2006 03:42 PM

Hmmm, seems possible to get it small enough to fit on a flash drive.

lee on November 4, 2006 10:55 AM

Yeah nLite is a kick ass software.
My favorite proggy!

Here is another useful resource for you article:

A hell what of nLite addons :)

Mike on December 1, 2006 10:51 AM

Jeff, great post. Thanks for your time in helping the rest of us by sharing your knowlege.


If you want a free tool for zeroing out the empty space of a drive use the, formerly sysinterals, product SDelete.exe. You can download it from here http://www.microsoft.com/technet/sysinternals/utilities/SDelete.mspx

Use the command:

>sdelete.exe -p 1 -c <driveletterwithcolon>

This will pass over all the empty space of the drive once and write zeros. I use a copy of the UBCD4Wim (http://www.ubcd4win.com) that I made to boot my VM and use the tool when not actively booted to the drive image I want to zero out.

Hope this helps some out there.

John Mitchell on December 29, 2006 12:34 AM

Another interesting idea: once the "base" drive image is created you can switch the virtualPC machine to use a differential drive based on the "base" drive. This differential drive can be kept in sync using FolderShare so you can use the same Virtual machine from different computers without many synchronization troubles.

Windows XP Tips on March 25, 2007 09:05 AM

Although this article applies to VPC 2004 - I've recently been working on creating a developer image and followed the steps here and had one small problem.

If you uninstall the indexing service for Windows, the search box in IE 7 is completely hosed. The only way I could get it to work correctly was to reinstall the service. I don't know why these two items are coupled together, but it's something to watch for.

Nicolas Webb on November 26, 2007 05:59 PM

Thanks for the great info. My motivation for shrinking down hosted versions of XP, is so the Virtual PC disk can fit into a Solid State Disk (also know as RAM disk). Programs there run faster (and quiter) since both OS and data are stored in RAM.

SteveK on March 14, 2008 11:25 PM

This is terrific! Wish I had the time to make a minimal XP VM like this myself. I'd probably not go quite as far as you-- I'd want to leave IIS and remote desktop access and a few other things like that in place. But having just spent two weekends banging my head against making the smallest VMs I could manage with Oracle databases and other apps pre-configured (the tightest one I could come up with compressed down to 5GB) seeing your example is a real inspiration. Maybe I can get down to an Oracle DB in Windows XP, compressed to fit on one DVD...

I was also using WinRAR, to make self-extracting images; maybe I should look at 7-Zip if it can do better.

vm addict on April 13, 2008 10:22 PM

If you need to defrag a win2k vm (Whitney degragger can't), JKDefrag is excellent

Doug on August 8, 2008 05:24 AM

After seeing this post, I was able to get my VMWare base XP Pro installation to 732MB. Using gzip (tar cvfz in Linux) I got it down to 269MB.

Amazing :D

C. Chu on October 7, 2008 05:33 PM

So I decided to screw around with Vista x64 for VMWare. I tried out vLite but every time I used a vLited installer it hangs before finishing install. Tried about 10 different configurations, at least.

You should release a new post on getting smaller Vista VMs :D

C. Chu on October 23, 2008 12:10 AM

Look, the Biggest Problem in my point of view, is not descrease more and more the size, due to if it takes the max full size 600MB, is ok for CD-R using way, BUT the Bisggest problem is to make it
AUTOEXECUTABLE, without Instalation of MS Virtual PC, or even First Run of POrtable Virtual PC, the challenge is make it 100% self-extract to a c: (kepping 600Mg in c:) and after seft-extract, AUTORUN, 100% using NAT conection for internet, and all drivers call from Host PC, if anyone got this and win this challenge keep us informed, lets make some versions of this .rar -sefextract and post it on Torrent Trackers,


Junior on November 21, 2008 05:29 PM

(hear it spoken)

(no HTML)

Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.
StatCounter - Free Web Tracker and Counter