Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My host OS is OS X Lion running a Windows XP client with VirtualBox 4.2.0. I'm wanting to make a copy of the image and compact it to share with a colleague. First, I used the VirtualBox command line to clone the image via clonehd.

VBoxManage clonevdi /path/to/image.vhd /new/path/to/image.vhd

Next, I tried compacting the image with the following command:

VBoxManage modifyhd /new/path/to/image.vhd --compact

In which I'm presented with the following error:

Progress state: VBOX_E_FILE_ERROR
VBoxManage: error: Failed to compact hard disk
VBoxManage: error: Could not compact medium '/new/path/to/image.vhd' (VERR_INVALID_STATE)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Medium, interface IMedium
VBoxManage: error: Context: "int handleModifyHardDisk(HandlerArg*)" at line 577 of file VBoxManageDisk.cpp

I've tried my hand at resolving the issue by searching, but I've came up empty handed up to this point. Any help will be greatly appreciated.

share|improve this question

You can only compact VDI images using the VirtualBox commandline as far as I know. You can use 3rd party tools to compact a VHD - Google is your friend.

If your host is Windows 7 or Windows Server 2008 R2, you should be able to use compact vdisk according to the page at

In the VirtualBox world, here's how...

VBoxManage modifyhd path\to\disk.VDI --compact

...if you've created a disk in a different format - e.g. VHD, exec the following command first...

VBoxManage clonehd "path\to\vhdformat.vhd" "path\to\vdiformat.vdi" --format vdi

See this example..., as well as this comprehensive example by Matt Wrock on how to optimise a VirtualBox VM, ready for packaging.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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