15 August 2006

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;)]

 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Dave English said:
Presumably you meant "reduce a VHD by some 300M or so"
16 August 06 at 4:12 AM
# Adam Bell said:
G'Day John.

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

Cheers

Adam
16 August 06 at 6:02 AM
# jhoward said:
So people do read my blog afterall ;)  Good spot guys. Thanks.
Cheers,
John.
16 August 06 at 1:45 PM
# col.fedmahnkassad@tiscali.fr said:
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
18 August 06 at 12:42 AM
# jhoward said:
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.
18 August 06 at 2:04 PM
# Wictor Wilen said:
This is a follow up post to my last about optimizing the Microsoft Virtual Server hard disks.
If y
20 August 06 at 5:46 AM
# Guillermo Taylor @ Microsoft said:

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

13 May 07 at 12:03 PM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 
Page view tracker