Page 1 of 1

VERR_INVALID_STATE error when compact VHD.

Posted: 13. Nov 2013, 04:57
by Michael7
Hi, pros,

I want to compact my VHD files as instructions but when i typed command as following:
vboxmanage modifyhd 'Windows XP.vhd' -compact

it fails.
and i searched this forum but there's no post with VERR_INVALID_STATE when compacting VHD.

these are my error messages:
VBoxManage: error: Failed to compact hard disk
VBoxManage: error: Could not compact medium '/Users/kuomichael/Documents/Windows XP.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 530 of file VBoxManageDisk.cpp

is anyone can help me to solve this problem??

Re: VERR_INVALID_STATE error when compact VHD.

Posted: 13. Nov 2013, 13:23
by mpack
Is there is a saved state associated with this VM? If yes then shut the VM down properly.

Did you run sdelete first, inside the guest?

And one more thing to confirm in the latest user manual... yes, here it is.
VBox User Manual section 8.23 wrote: Please note that compacting is currently only available for VDI images. A similar effect can
be achieved by zeroing out free blocks and then cloning the disk to any other dynamically
allocated format. You can use this workaround until compacting is also supported for disk
formats other than VDI.
Basically, if you want the full range of VirtualBox hd functionality, you have to be using the VirtualBox native container format. I have no idea why someone on a Mac host would use VHD!

Another alternative is to compact the disk using CloneVDI (under Wine). This accepts VHD as input, producing a VDI. With CloneVDI you do not need to run sdelete first, so it should be much faster.

Re: VERR_INVALID_STATE error when compact VHD.

Posted: 17. Nov 2013, 16:33
by Michael7
thank you , mpack.

I use VHD filetype because I used to be a micro$oft user... and their VMware use this filetype.

based on your opinion, I successfully compact my virtual machine file.

I use the command : VBoxManage clondhd to convert my file into VDI.

and after this step, it can be compacted successfully.

thank you for your suggestion.