sprotheroe / vagrant-disksize

Vagrant plugin to resize disks in VirtualBox
MIT License
479 stars 51 forks source link

Removal of old disk after cloning corrupts medium reference in VirtualBox #16

Closed EmersonPrado closed 6 years ago

EmersonPrado commented 6 years ago

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

The method should properly remove old media

EmersonPrado commented 6 years ago

Opened PR 17

sprotheroe commented 6 years ago

PR merged, so closing this issue. Thanks for all your contributions (and your incredible patience!).