John Howard - Senior Program Manager in the Hyper-V team at Microsoft

Senior Program Manager, Hyper-V team, Windows Core Operating System Division.

VHD Size Reduction

VHD Size Reduction

  • Comments 7
  • Likes

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
  • Presumably you meant "reduce a VHD by some 300M or so"

  • G'Day John.

    Err, 300K? I presume this is a typo? ;)

    Cheers

    Adam

  • So people do read my blog afterall ;)  Good spot guys. Thanks.
    Cheers,
    John.

  • 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

    denis

  • 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 Files\Microsoft Virtual PC\Virtual 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.

  • This is a follow up post to my last about optimizing the Microsoft Virtual Server hard disks.
    If y

  • La semana pasada estuve generando contenido y demos para nuestro producto Business Desktop Deployment

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment