2

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?

0

6 Answers 6

6

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.

1
  • 2
    +1 for "you didn't read the help file hard enough" Aug 7, 2009 at 8:09
3

You could follow the steps described here.

1

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.

1

Ignore all of the suggestions that require you to run through long lists of complicated steps (such as the one at http://kb.dutchalps.com/microsoftvirtualpc.htm). Ignore all of the suggestions that require you to use a third-party tool (such as the suggestion to use Eraser).

All you need to do is defrag the VHD and then run the Virtual Disk Precompactor from Microsoft. It is an ISO image that you can mount in the virtual machine and can be found in the Virtual Machine Additons directory. After running the Virtual Disk Precompactor you can let Virtual PC compact the VHD.

Note that these comments apply to Virtual PC 2007.

0

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.

0

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.

You must log in to answer this question.