Resize VirtualBox harddisk in Windows with VBoxManage with bypassing registering error

If you want to resize a virtual harddisk for a VirtualBox machine under Windows, you can use VBoxManage utility, as follows:

& ‘C:\Program Files\Oracle\VirtualBox\VBoxManage.exe’ modifyhd “.\Ubuntu14-04LTS.vdi” —-resize 30000

where the resize attribute specifies the new bigger size in megabytes.
Note: Before doing that, do a copy of the VDI file and detach the harddrive from the VM.

If you receive an error like

VBoxManage.exe: error: Cannot register the hard disk ‘c:\path_to_vdi\Ubuntu14-04LTS.vdi’ {xyzxyz-xyzxyz-blah-blah-…}
because a hard disk ‘c:\path_to_vdi\Ubuntu14-04LTS.vdi’ with UUID {xyzxyz-xyzxyz-blah-blah-…} already exists
VBoxManage.exe: error: Details: code E_INVALIDARG (0x80070057), component VirtualBox, interface IVirtualBox, callee IUnknown
VBoxManage.exe: error: Context: “OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())” at line 178 of file VBoxManageDisk.cpp

you can do one of the following:

  • & ‘C:\Program Files\Oracle\VirtualBox\VBoxManage.exe’ modifyhd “.\Ubuntu14-04LTS.vdi” —-resize 30000
  • In VirtualBox application, go to File menu, Virtual Media Manager … and delete the entry for your VDI file, after which you’ll have to add it again from Storage menu

Note 0: Commands were executed under PowerShell, that’s why they have an & before the path of VBoxManage. If you use command line, remove it.
Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: