VHD Size Reduction
So there's many tricks to optimising the size of a VHD. One which I always use, but appears not to be widely known about, is to turn of the system file checker. Of course, this has it's downsides and your mileage may vary. In practice you can reduce a VHD by some 300M or so on an instance of Windows 2003 SP1.
To turn off SFC, open a command prompt (must be elevated if run on Windows Vista or Longhorn Server) and run
sfc /cachesize=0
sfc /purgecache
Then perform the standard compaction routine (if this is a dynamically expanding disk).
Cheers,
John.
[Corrected 8/16 as per comments, 300K isn't much of a saving. I did indeed mean 300MB;)]
Comments
Anonymous
January 01, 2003
La semana pasada estuve generando contenido y demos para nuestro producto Business Desktop DeploymentAnonymous
January 01, 2003
This is a follow up post to my last about optimizing the Microsoft Virtual Server hard disks.
If yAnonymous
August 16, 2006
Presumably you meant "reduce a VHD by some 300M or so"Anonymous
August 16, 2006
G'Day John.
Err, 300K? I presume this is a typo? ;)
Cheers
AdamAnonymous
August 16, 2006
So people do read my blog afterall ;) Good spot guys. Thanks.
Cheers,
John.Anonymous
August 18, 2006
Hello John,
Sorry to be a newbee (and more: a french newbee...) but I tried to reduce a VHD Size, and I don't know how "perform a standard compact routine".
I use Virtual PC, and not Virtual Server, is it important?
Thanks for all
denisAnonymous
August 18, 2006
Hi Denis - welcome to Virtual PC :)
The "Standard Compaction" routine I referred to, and applies to dynamically expanding hard disks has a few steps:
- Make sure undo disks are not turned on. If they are, shut the guest down, merge undo disks and turn them off.
- From inside the guest, defragment the hard disks (a few times if possible)
- From the host, mount the Virtual Disk Precompactor.iso into the guest. By default this is in Program FilesMicrosoft Virtual PCVirtual MAchine Additions folder (IIRC)
- From the guest, the precompactor should auto-run. If it doesn't run the utility manually from the D: drive or whatever the CD/DVD drive is in the guest
- Shut the guest down
- From the host, go into the settings for the Virtual Machine
- Select the hard disk and click "Virtual Disk Wizard"
- From the wizard, Edit an existing virtual disk
- Browse to your VHD
- Choose the compact option
That should be it! The semantics are slightly different under Virtual Server in that you "Inspect" a disk from the web interface, but the steps needed in the overall process are exactly the same.
Cheers,
John.