<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bohack &#187; Virtual PC</title>
	<atom:link href="http://www.bohack.com/category/windows/virtual-pc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bohack.com</link>
	<description>Check In and Tune Out!</description>
	<lastBuildDate>Sun, 08 Jan 2012 20:59:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Compacting Microsoft Virtual PC VHD Images 101</title>
		<link>http://www.bohack.com/2009/05/compacting-microsoft-virtual-pc-vhd-images-101/</link>
		<comments>http://www.bohack.com/2009/05/compacting-microsoft-virtual-pc-vhd-images-101/#comments</comments>
		<pubDate>Mon, 25 May 2009 17:14:07 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Virtual PC]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=258</guid>
		<description><![CDATA[I&#8217;ve been using Microsoft&#8217;s Virtual PC for the past 7 years, ever since I spoke with a kernel developer at Microsoft and found that they solely use Virtual PC for debug and development. Since then I have used it to build images and teach in the classroom as a learning device. It allows me to [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/05/compacting-microsoft-virtual-pc-vhd-images-101/' addthis:title='Compacting Microsoft Virtual PC VHD Images 101 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Microsoft&#8217;s Virtual PC for the past 7 years, ever since I spoke with a kernel developer at Microsoft and found that they solely use Virtual PC for debug and development. Since then I have used it to build images and teach in the classroom as a learning device. It allows me to teach with what I call a surgical approach, because every lab is perfectly clean every time for every student. However it is all about the footprint when it comes to storage of the Virtual Hard Drives, sometime you need to keep several VHD images around. So over the past few years I have put a collection of tools together that lead to the best compaction method.</p>
<p><span id="more-258"></span>To compact a VHD it is a two part process; the first part is done in the guest operating system, with a general cleanup. The second part of the process is completed by booting into RAM a second guest OS that can manipulate the original guest&#8217;s virtual hard disk. At this point we can further delete some files and truly defragment the VHD.</p>
<p>So first we begin by booting the guest Operating System and cleaning it up of unnecessary files. You can start by opening the %systemroot% and deleting any service pack or system update uninstalls, they usually look like &#8220;$NtUninstallKB952069_WM9$&#8221;. By doing this you can shave almost 1GB of space or more, depending on how old the image is and how many updates have been done. Next drop the &#8220;Restore Points&#8221; if you are dealing with Windows XP, just go in to My Computer properties under the &#8220;System Restore&#8221; tab and check &#8220;Turn off System Restore on all drives&#8221;. By doing this you can cut the VHD down by up to 10%, again it all depends on how old the OS is and how many restore points it has retained. The next step is to right click on the C drive or Local Disk, go to properties and select &#8220;Disk Cleanup&#8221;. Do not compress old files, but delete temporary Internet Files and downloaded content junk&#8230; etc&#8230; Again this can sustainably free up space on the drive.</p>
<p>At this point we have cleaned up the guest operating system as much as possible. Now we need to boot into a live install of Window that is in RAM and run some tools. The best way and quickest way is to download a Bart’s PE toolkit and make a custom Bart’s PE ISO; you can find this toolkit at http://www.nu2.nu/pebuilder/.</p>
<p>You will need to add two programs to the Bart’s PE disk; the first is a standalone defrag tool the second is the precompaction.exe from the ISO in the Virtual PC program files. I will explain… The best tool to defrag with is a program by Dave Whitney, however it’s hard to find. My suggestion is to Google “Dave Whitney defrag”; Dave’s current web site is “The Flexomizer”. This defrag will work stand alone and give you just about 100% defragmentation on the disk. The second tool is an executable named “Precompact.exe” in an ISO named “Virtual Disk Precompactor.iso” located in “C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\”. Use daemon-tools and remove the executable to be included in the Bart’s PE build following the Bart’s PE directions to build the bootable Bart’s PE ISO.</p>
<p>Now boot the Virtual PC containing the VHD with the Bart’s PE ISO created with the tools above. Once booted up open a command prompt and switch to “C:” which is your original VHD hard drive. We need to remove the “pagefile.sys” and “hiberfil.sys”, both of these can shave gigabytes of data off the VHD. First “attrib –r –s –h pagefile.sys”, then delete it and then repeat this for the “hiberfil.sys” file. Now defrag the C drive with the new defrag tool you downloaded from Dave Whitney’s web site. Now that we have defragged the VHD it’s time for the pre-compaction, by running the precompact.exe tool. This tool will zero and bytes unused be the defrag process; you can it is basically like repairing and compacting a database.</p>
<p>Once the tool is done shutdown the Virtual PC and go into the disk wizard and click on edit an existing disk and compact the disk replacing the original disk. When it goes thru this process it will create a second file and replace the first file, so the file will be somewhat contiguous. However if you wish you can always run the “contig” program from the Microsoft System Internals web site; this can speed the VHD up.</p>
<p>It’s actually a pretty simple process:</p>
<p>1.    Clean up the guest operating system, deleting any old junk.<br />
2.    Boot a Live version (RAM resident) of Windows.<br />
3.    Delete the page file and hibernation file.<br />
4.    Defragment the hard disk.<br />
5.    Precompact the hard disk.<br />
6.    Shut down and compact the hard disk.<br />
7.    Optionally run the contig program to defrag the file.</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.bohack.com/2009/05/compacting-microsoft-virtual-pc-vhd-images-101/' addthis:title='Compacting Microsoft Virtual PC VHD Images 101 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/05/compacting-microsoft-virtual-pc-vhd-images-101/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

