Use “sdelete -z” when Shrinking a Windows Guest’s Virtual Hard Drive

I was installing Windows 7 in a VirtualBox Virtual Machine, and tried to shrink the dynamic virtual hard drive (vdi format). There are several guides out there explaining how to do this. SDelete is commonly used to zero out the virtual hard drive’s free space before compacting the hard drive file.  As the SDelete manual page states, “-z” is the correct option to use for this purpose.  However, many of the guides I read use the “-c” option.  This is counterproductive since it results in random data being written to the free space, thus causing the virtual hard drive file to expand to its maximum size (in my case, this filled my host PC’s hard drive).  This issue has been discussed quite a bit in forums and blog comments; “-c” at one time was the correct option to use, but the semantics of the “-c” and “-z” options changed with one of the recent SDelete releases (I understand it was with version 1.6).

Conclusion: With the latest version of SDelete, use the “-z” option when you are shrinking a virtual hard drive.

As a side note, it took a long time for SDelete to finish on my machine – I think it was because I made my virtual hard drive very large.  I chose a size much larger than I actually needed, since I thought there would be no disadvantage to having too much space (since it is a dynamic drive, the extra virtual space takes no physical space).  In hindsight, maybe I should have chosen a smaller size.

 

Update: I found this blog entry, which has a similar post.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: