After cloning the disk, method Vagrant::Disksize::Action::ResizeDisk.ensure_disk_resizable removes old disk file, but leaves its reference in VirtualBox. This makes the disk appear as broken in VB media manager, and we have to manually remove it:
$ VBoxManage showmediuminfo <UUID>
...
State: inaccessible
Access Error: Could not open the medium '<Old disk path>'.
VD: error VERR_FILE_NOT_FOUND opening image file '<Old disk path>' (VERR_FILE_NOT_FOUND)
...
The broken reference sometimes break VM recreation thru destroy and up:
There was an error while executing `VBoxManage`...
Command: ["clonemedium", "<Old disk path>", "<New disk path>", "--format", "VDI"]
Stderr: VBoxManage: error: UUID {<UUID>} of the medium '<Old disk path>' does not match \
the value {<Different UUID>} stored in the media registry ('.../VirtualBox.xml')
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MediumWrap, \
interface IMedium, callee nsISupports
VBoxManage: error: Context: "CloneTo(pDstMedium, ComSafeArrayAsInParam(l_variants), NULL, \
pProgress.asOutParam())" at line 892 of file VBoxManageDisk.cpp
After cloning the disk, method Vagrant::Disksize::Action::ResizeDisk.ensure_disk_resizable removes old disk file, but leaves its reference in VirtualBox. This makes the disk appear as broken in VB media manager, and we have to manually remove it:
The broken reference sometimes break VM recreation thru
destroy
andup
:The method should properly remove old media