<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Guoqiang Wu's Blog : Testing</title><link>http://blogs.msdn.com/guowu/archive/tags/Testing/default.aspx</link><description>Tags: Testing</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Creating LEAN_AND_MEAN Virtual Hard Disk (.vhd) Files</title><link>http://blogs.msdn.com/guowu/archive/2005/05/17/418457.aspx</link><pubDate>Tue, 17 May 2005 10:14:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:418457</guid><dc:creator>guowu</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/guowu/comments/418457.aspx</comments><wfw:commentRss>http://blogs.msdn.com/guowu/commentrss.aspx?PostID=418457</wfw:commentRss><description>&lt;div&gt;Not so recently I discovered a way that can significantly reduce VHD file sizes: I was able to reduce the sizes of all my VHDs down to 100MB or less bigger than what their guest operating systems report. Just today I compacted a Japanese Windows XP SP2 VHD  with a OS reported size of 1.70GB to 1.72GB, whereas the standard procedure can only get down to about 2.3GB. If you are obsessed, like me, in reducing the size of bloated VHDs, you'd know this result is just amazing.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;The secret turns out to be very simple. As you may already know, the standard procedure to compact dynamic expanding VHDs is as the following:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div align="left"&gt;1) Inside the VM, run disk defragmenter&lt;/div&gt;&lt;div align="left"&gt;2) Inside the VM, run Virtual Disk Precompactor or other disk utility program to "zero out" deleted data&lt;/div&gt;&lt;div align="left"&gt;3) Shutdown the VM, run "Virtual Disk Wizard" from VPC console to compact the VHD.&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;And the key lies in step 1. Instead of using the defragmenter comes with Windows, you should use the one created by Dave Whitney, which can be download for free &lt;a href="http://www.whitneyfamily.org/Hacks/?item=Defrag"&gt;here&lt;/a&gt;. The special thing about Dave's defragmenter is that it can defrag not only occupied spaces, but also free spaces. If you think about it, this totally makes sense why it helps compacting the VHDs. So far my experience is that no matter how the image is built and how bloated the virtual disk is, this procedure will give you the real size!&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;Of course, nothing comes without cost. From my experience, it takes 5 to 10 more minutes to finish than the Windows defragmenter. It could take much longer if the disk size is bigger. However, considering the huge saving on disk spaces(500MB per disk at the least) and the network bandwidth if you are distributing them to others, it is definitely worth the extra wait. What is more, I suspect the guest OS performance would be better. No hard evidence on that though.&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;One thing to clarify: I usually relocate page files to a secondary virtual disk therefore all disk sizes I mentioned here do not include the page files: because they usually have big reported sizes, but actually take little space on the disk, it may give you false sense of compactness. If you ever make the size of your VHD smaller than what guest OS reports, I am almost certain that you have page files included in the equation.&lt;/div&gt;&lt;div align="left"&gt; &lt;/div&gt;&lt;div align="left"&gt;At last, this is totally my personal experience (and opinion). Your experience may vary. I would be very interested to know how it works on very big VHDs. So please do report back your result if you try this on VHDs bigger than 8G, 10G, or maybe even 16G.&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=418457" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/guowu/archive/tags/Testing/default.aspx">Testing</category></item></channel></rss>