Compact Your VHD Files
Many times it's necessary to debug solutions on other machines so that you don't corrupt your developer machine, because of different platform requirements, or to attach a debugger without changing the state of the machine. Testing Windows Installer patches is no different. We test on daily target builds using daily upgrade builds. Installing daily builds isn't always such a good idea, and because Windows Installer now caches MSP re-installing a patch with slightly different contents but the same PatchCode proves difficult.
Of course we have labs full of machines, but because these run through a complete installation of both the OS and other components such as service packs and lab tools, I prefer Microsoft Virtual PC and Virtual Server. Both at home and at work I've got a good base build with very little installed, including the latest service packs, hotfixes, and the Visual Studio .NET 2003 native remote debugger. Once that's all set up, I enable undo disks. Now whenever I need to start over I simply turn off the virtual machine and discard the changes. When I restart I have a fresh new machine.
In order to decrease disk space requirements, you have to compact your virtual hard disks, or VHD files. If you run the Virtual Disk Wizard from the File menu and choose to edit and compact an existing VHD, the wizard states that, "Before you compact this virtual hard disk, you must zero out free space on it with a third-party tool that you install on the guest operating system." The CHM file for Virtual PC 2005 Service Pack 1 has a similar message. Finding such a tool wasn't so easy. SDelete from Sysinternals starts by zeroing free space, but then fills it with 0xff and then random bytes. It also grows the size of a dynamic disk because it creates a file to fill all available space which most likely hasn't been allocated yet in the VHD.
Before writing such a utility I, of course, tried Microsoft Support. I was able to find one KB article — KB 888760 — that made mention of such a tool, which was not a third-party tool at all.
Download and install Virtual PC 2004 Service Pack 1. (or virtual Pc 2007 server pack 1)
Defragment your guest operating system.
From the CD menu, select Capture ISO Image and browse to the Virtual PC additions directory, which is "%ProgramFiles%\Microsoft Virtual PC\Virtual Machine Additions" by default.
Mount Virtual Disk "Precompactor.iso." By default with auto-run enabled, the precompactor will start automatically.
When it has finished, unmount the ISO from the CD menu. and stop the
Virtual machine, the
Run the Virtual Disk Wizard from the File menu and follow the instructions to compact your VHD file. (select the exist vhd , next , will have two option , one is compact the disk one is change to fix volume, compact function can be reduce the size of your base VHD file. When it's finished, click Settings to open the settings for your virtual machine, select Undo Disks, and check Enable Undo Disks.
No comments:
Post a Comment