Geeks With Blogs


Google My Blog

Murray Gordon Flash a-ah! Savior of the universe...


I found this great post on John Galloway's blog about compressing Microsoft Virtual PC *.vhd files. You can find the original post at the following link ([VPC] Compressing VHD files [VPC] Compressing VHD files). The problem John discusses is one I think we have all found to be true. We have definitley struggled with this one for a while. Our solution has been to use WinRAR to create a multiple file executable. That way if we are too large, then atleast we can break the unzip onto a couple DVDs. The single DVD mark is pretty tough to make when you have XP Professional, Visual Studio 2005, SQL Server 2005, Adobe Acrobat, Office 2003, Infragistics NetAdvandtage 2005, Host Integration Server, Verastream Host Integrator Design Tool, BizTalk Server and SharePoint Portal Server all on the same machine.

So personally, I haven't found 7zip to be too useful, but WinRAR really works for me. Make sure and set aside some time to create the complete the compression. It usually takes about and hour and a half.

But for those of you who have found 7zip to be helpful, check out John's post excerpt below:

 VHD files or “virtual harddisks“ are one of the two files needed by Virtual PC to load a virtual operating system. The other file is refererred to as a *.vmc or configuration file.

Lately, we have been 're shuttling VHD files around the office to share preconfigured developer environments. Even precompacted, VHD files are still pretty huge - 5 to 10 GB. They can compress down quite a bit, though - as much as 70% or so.

The built in "compressed file" support in Windows can choke on files this size. I've been using 7-zip, a free compression program, to shrink mine. It includes support for ZIP, but self-extracting SFX's can cut a few hundred more MB's off the file size. That can save several minutes on a network file copy, or make the difference between whether the file will fit on a DVD. For example:

VHD - 5.4GB
Zipped VHD - 2.1GB (38%)
SFX VHD - 1.7GB (31%)

Here are some batch files which I'm using to compress the images. They use the command line version of 7-Zip.  I'm sure these batch files can be improved, or I could add a right click option to VHD files or something - I'm open to suggestions. The main thing I wanted to share, though, is the command line settings for max compression SFX and ZIP compression:

SFX (Self Extracting EXE):

cd "d:\virtual machines\VS2005\"
c:\tools\7zip\7za.exe a -sfx -mx=9 VS2005Beta2.exe VS2005Beta2.vhd


cd "d:\virtual machines\VS2005\"
c:\tools\7zip\7za.exe a -tzip VS2005.vhd -mx=9

Posted on Friday, September 16, 2005 12:00 AM Virtual PC | Back to top

Comments on this post: [VPC] Compressing VHD files

# re: [VPC] Compressing VHD files
Requesting Gravatar...

I want to use decompress one vhd file to my usb flash(E: for example). How can we do that using a programming language like visual C++.

Left by Abdelkader YEDDES on Jan 05, 2006 2:16 AM

# re: [VPC] Compressing VHD files
Requesting Gravatar...
Sorry, not really sure what you mean. You can execute the 7za.exe as a shell command from a c++ application. But I'm not sure that is answering your question. Give me some clarification and I might be able to give you some more help.

Left by Murray Gordon on Jan 09, 2006 8:29 AM

Your comment:
 (will show your gravatar)

Copyright © Murray Gordon | Powered by: