VERR_INVALID_STATE error when compact VHD.

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
Michael7
Posts: 2
Joined: 13. Nov 2013, 04:53

VERR_INVALID_STATE error when compact VHD.

Post 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??
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: VERR_INVALID_STATE error when compact VHD.

Post 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.
Michael7
Posts: 2
Joined: 13. Nov 2013, 04:53

Re: VERR_INVALID_STATE error when compact VHD.

Post 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.
Post Reply