Talking about HOWTO: Compress Virtual PC virtual hard disks (.VHDs)

 

Quote

HOWTO: Compress Virtual PC virtual hard disks (.VHDs)

If you use Virtual PC 2007 you know that the virtual hard drive files (.VHDs) can grow to extremely large sizes.  Part of this is because the .VHD files dynamically expand when software is installed in the .VHD however after the installation, the original setup files are deleted and no longer take up space in the .VHD, however the .VHD does not correspondingly dynamically shrink in size.  Once a .VHD file expands – it doesn’t shrink. 

EXAMPLE:  If the installation of a product like Microsoft Office uses 500MB to expand it’s setup files and consumes 340MB in the \Program Files directory the .VHD file expands accordingly.  When the 500MB of setup files are subsequently deleted after the installation has completed, the .VHD file doesn’t shrink accordingly.

Normally, people don’t care about file size bloat that much however when you’re using Virtual PC .VHDs you may be talking about 3-4GB of wasted storage or more.  So the question is, "How do I shrink the size of a .VHD when I know it’s inflated unnecessarily?" 

Here’s how to do it:

  1. Clear out the machine of filler
    I recommend installing CCLEANER.EXE from http://ccleaner.com which deletes all temporary files from the Windows installation, Internet Explorer cache, the Recycle Bin, and any number of other "garbage"/"temp" directories in the VPC.
  2. Disable hibernation
    If you have hiberation turned on, there’s a colossal sized file called hiberfil.sys in the root of the .VHD.  Go into Power options in Control Panel and disable hiberation to get rid of this file.
  3. Capture the Virtual Disk Precompactor .ISO
    In the menu of Virtual PC windows for your machine, capture the Virtual Disk Precompactor .ISO file which is located at:
    c:\program files\microsoft virtual pc\virtual machine additions\virtual disk precompactor.iso
  4. Run the Precompactor
    Go to My Computer and double click on the mounted disk.  It will begin to run the precompactor software which will essentially zero out all the free space on the disk, making it available for elimination from the file by the Virtual Disk Wizard, which we will use later.  This process may take upwards of 15 minutes
  5. Shutdown the Virtual PC
  6. Run the VPC2007 Virtual Disk Wizard
    From the Virtual PC console, click File-Virtual Disk Wizard and "Edit an existing virtual disk".  It will ask you to identify the .VHD file to reduce in size – select it.
  7. Compact the .VHD
    Select the "Compact" option then select "Replacing the original file".  This will take a few minutes.

When this process finishes, you should have a .VHD file with a much smaller size.

白求恩遗嘱

诺尔曼·白求恩(Norman Bethune, 1890.03.03-1939.11.1) 加拿大著名胸外科医生。抗日战争爆发后,他受加拿大共产党和美国共产党的派遣,率领医疗队来到中国,援助中国人民抗日战争。后抢救伤员时感染病毒,于1939年11月12日在河北省逝世。


亲爱的聂司令员:
  今天我感觉身体非常不好,也许我要和你们永别了!请你给加拿大共产党总书记蒂姆·布克写一封信,地址是加拿大多伦多城威灵顿街十号。同时,抄送国际援华委员会和加拿大民主联盟会。告诉他们,我在这里十分快乐,我惟一的希望就是能够多做贡献。
  也要写信给美国共产党总书记白劳德,并寄上一把缴获的战刀。这些信可以用中文写成,寄到那边去翻译。随信把我的照片、日记、文件寄过去,由蒂姆·布克处置。所有这些东西都装在一个箱子里,用林赛先生送给我的那18美金作寄费。这个箱子必须很坚固,用皮带捆住锁好,外加三条绳子。将我永世不变的友爱送给蒂姆· 布克以及所有我的加拿大和美国的同志们。
  请求国际援华委员会给我的离婚妻子坎贝尔夫人拨一笔生活款子,分期给也可以。我对她应负的责任很重,决不能因为没钱而把她遗弃了。还要告诉她,我是十分内疚的,并且曾经是快乐的。
  两张行军床、两双英国皮鞋,你和聂夫人留用吧。
  马靴、马裤,请转交吕司令。
  贺将军,也要给他一些纪念品。
  两个箱子,给叶部长;18种器械,给游副部长;15种器械,给杜医生;卫生学校的江校长,让他任意挑选两种物品作纪念。
  打字机和绷带给郎同志。
  手表和蚊帐给潘同志。
  一箱子食品和文学书籍送给董同志,算我对他和他的夫人、孩子们的新年礼物。
  给我的小鬼和马夫每人一床毯子,另送小鬼一双日本皮鞋。
  照相机给沙飞。
  贮水池等给摄影队。
  医学书籍和小闹钟给卫生学校。
  每年要买250磅奎宁和300磅铁剂,用来治疗疟疾患者和贫血病患者。千万不要再到保定、天津一带去购买药品,那边的价钱要比沪、港贵两倍。
  最近两年,是我平生最愉快、最有意义的日子。在这里,我还有很多话要对同志们说,可我不能再写下去了。让我把千百倍的谢忱送给你和千百万亲爱的同志们。
白求恩


TechNet Webcasts