VMware Communities
CathalMacFadden
Contributor
Contributor

A way to speed up shrinking of virtual drives.

I came up with a way to speed up the shrinking of virtual disks (.vmdk files).

When shrinking using the "Shrink" tab in vmware tools there are two steps.

1. Prepare to shrink

2. Shrink.

The first step Prepare to shrink simply creates 2GB files on the virtual drives selected until the drives are full.

This takes a very long time if you have drives with alot of free space.

I have written a program which performs most of the prepare step in under a second. I have attached the program and the c# source code.

Requires Microsoft .NET 2.0

How to use:

1. Copy the SpeedShrink.exe to your virtual machine.

2. Run the program. Select the drives you intend on shrinking.

3. Click the "Start" button. You will be prompted when it has completed.

4. Run the Preparation step as normal. Should only take a minute or so compared to 20, 30, 40 minutes depending on how much space you are shrinking. See how to shrink section below if you dont know how to do this.

5. When VMWARE tools has completed the prepare step press YES to shrink the drives. The speed of this step will remain the same.

6. Once the shrink has been completed press Cleanup which will remove any of the files created in step 3. Sometimes they dont get automatically removed by vmware.

7. Done. Your VMDK files should now be shrunk.

Tested on VmWare Player 3, 4 on Server 2003, XP, Win7, server 2008

How to shrink:

1. In the system tray of your virtual operating system you will have a VMWARE tools icon (If you dont then install vmware tools)

2. Double click on it and select the Shrink tab.

3. Select the drives you wish to shrink.

4. Press "Prepare to shrink"

NOTE: THE SHRINKING PROCCESS REQUIRES FREE SPACE ON YOUR PHYSICAL MACHINE EQUAL TO THAT OF THE TOTAL SIZE OF THE DRIVES SELECTED.

Tags (4)
0 Kudos
6 Replies
continuum
Immortal
Immortal

Just curious ....
your tools creates the wiperfiles very fast - as fast as fsutil.exe or fsz.exe would.

What exactly does the tool do ? - just creating the files is not the important part - to be effective writing zeroes is required.

I wonder if your tool can do this in such a short time


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos
CathalMacFadden
Contributor
Contributor

spot on.

It pretty much just automates FSUTIL.exe to create the files in the same size as VMWARE does.

0 Kudos
CathalMacFadden
Contributor
Contributor

I just re-read your post.

You say i need to write zeros in order for it to work.

I have not had that experince. My attached method works fine unless it was some coincidence that all the VM's i tested were zeroed free space!

0 Kudos
continuum
Immortal
Immortal

I was wondering about the same thing - by the way - I occasionally use fsutil to create preallocated vmdks when I am in a hurry.

If I remember right fsutil creates files in sparse mode. That means it just allocates the required space but does not actually write them out completely.

We would have to create a test scenarion that gives reliable results ....

Try this: create 2 growing type vmdk of the same size - let say 4 Gb.

Add them to a VM and format them.

Then download a Knoppix iso and copy it as many times as possible.

That would give 2 vmdks with 5 Knoppix isos a 700 Mb stored on each of the two vmdks - for example.

Next delete all 10 isos and empty the trashbin.

Now use your wiperfiles on one vmdk and the VMware-procedure on the other vmdk.

I would expect that the VMware wiperfile will shrink the vmdk to a final size of maybe 50 Mbs.

With fsutil I would expect a significantly larger vmdk - I would guess at least 200 MB.

But thats just a guess - I would like to see the results of that comparison..


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

CathalMacFadden
Contributor
Contributor

Yes you seem to be correct.

The database does not shrink by the amount of my created files.

Odd. I wonder why in my original tests i did see it shrink. Must have been preallocated with zeros from some something else.

I guess ill have to look into another method.

0 Kudos
continuum
Immortal
Immortal

have a look here:
http://www.feyrer.de/g4u/#shrinkimg

that guy lists some other tools to wipe the disk before shrinking

or just create a 1Mb file with zeroes and copy it until the disk is full


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos