vote up 1 vote down star
1

Hi all,

I have a Virtual machine hard disk over 20GB in size. But there are only about 8-10GB of files inside.

I need to shrink this vhd file to a more manageable (actual) file size. I've tried using the virtual PC wizard and it doesn't do anything with the file size.

Is there any other solutions or tools that I can use to shrink the vhd file size?

flag
belongs on serverfault – Paul Dixon Aug 7 at 7:42
Belongs to me! Everything belongs to me! Muhahahahaha! – Vilx- Aug 7 at 8:07

migrated from stackoverflow.com

6 Answers

vote up 3 vote down

Hi,

You could follow the steps described here.

link|flag
vote up 3 vote down

Actually, Microsoft Virtual PC already has an option called "Compact virtual disk". Read about it in the help file. However, to achieve the best reduction you will need to zero-fill the empty parts of the disk. For that you will need a third party tool - but there are plenty of those. Just google.

Sorry, misread your post. You already tried that. In that case you didn't read the help file hard enough. I quote:

Before compacting the disk, we recommend that you use a disk utility to zero out blank space, which should result in a smaller compacted virtual hard disk.

I use a utility called Eraser. I think it was recommended in some Microsoft TechNet posting or MSDN. And it's totally free.

link|flag
1  
+1 for "you didn't read the help file hard enough" – Tiberiu Ana Aug 7 at 8:09
vote up 2 vote down

Put it in the dryer.

link|flag
1  
-1 Oh so funny. – balpha Aug 7 at 7:53
1  
It's Friday man, smile! – Max Aug 7 at 8:03
vote up 0 vote down

I've always used this: http://vmtoolkit.com/files/folders/converters/entry87.aspx

Make sure you have shrunk the partition in the vhd first using the tools you've already used, the resizer should then allow you to shrink the vhd file itself to match the partition size.

link|flag
vote up 0 vote down

If your disk is dynamic sized :

  1. Defragment (you could use the Whitney defragmenter).
  2. Compact the disk with Virtual PC (more information here).

If you have a fixed size disk, I guess you could create another smaller disk and backup/restore the first one on the second one (using a ghost utility like Clonezilla). You would have to defragment first in this case too.

To create smaller disks in the first place, follow Jeff's advice.

link|flag
vote up 0 vote down

Applicable only on sparse disk images, you need to zero out the empty space and then use the shrink utility. That will perform a zero-de-dup on the image.

Preallocated images are preallocated, no way to shrink them.

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.