VirtualBox harddisk registry is corrupted
Posted: 16. Dec 2021, 11:24
On Windows10 hosts sometimes I get in a state where the VirtualBox harddisk registry is corrupted. In this state all VBoxManage commands fail with following error:
VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Cannot register the hard disk 'C:\xyz.vmdk' {e71033b4-26d4-47bd-842c-903a9cf59b65} because a hard disk 'C:\xyz.vmdk' with UUID {b301353b-b126-4709-9091-1609da297756} already exists
Is there a way via VBoxManage (or via VBox interop dll) to get out of this state?
At the moment I use a manual workaround. From VirtualBox.xml I remove all <Harddisk> entries under <MediaRegistry\Harddisks> and restart the PC.
Generally I do all commands via VBoxManage. I use an own storage location for the image files (vmdk, vhd). But when I delete a VM the used image remains in list of harddisks, "VBoxManage.exe list hdds" shows still the unregistered image.
I suppose this could be the reason for the message "Cannot register the hard disk because a hard disk with UUID already exists".
Create a VM is done as follows:
VBoxManage.exe createvm --register --name "%VM_NAME%" --ostype Debian_64
VBoxManage.exe storageattach "%VM_NAME%" --storagectl flash --port 0 --device 0 --type hdd --medium "%VM_IMAGE%" --setuuid ""
Delete a VM is done as follows (the image should not be deleted):
VBoxManage.exe storageattach "%VM_NAME%" --storagectl flash --port 0 --device 0 --type hdd --medium none
VBoxManage.exe closemedium disk "%VM_IMAGE%"
VBoxManage.exe unregistervm "%VM_NAME%" --delete
For one image (eg. C:\xyz.vmdk) the Create-VM/Delete-VM is done multiple times, eg:
Create-VM with C:xyz.vmdk, start this VM, Delete-VM and then again Create-VM with C:xyz.vmdk, start this VM, Delete-VM.
When using the GUI "Oracle VM VirtualBox Manager / Manager for virtual media" with the "Remove" button the image disappears from output of "VBoxManage list hdds" output.
Generally it is no problem if the unregistered images remain in harddisk registry (output of VBoxManage list hdd) but as I mentioned sometimes my VirtualBox is fully damaged with the "harddisk UUID conflict".
I tried different VirtualBox version (6.1.20, 6.1.22, 6.1.24, 6.1.28).
VBoxManage.exe: error: Failed to create the VirtualBox object!
VBoxManage.exe: error: Cannot register the hard disk 'C:\xyz.vmdk' {e71033b4-26d4-47bd-842c-903a9cf59b65} because a hard disk 'C:\xyz.vmdk' with UUID {b301353b-b126-4709-9091-1609da297756} already exists
Is there a way via VBoxManage (or via VBox interop dll) to get out of this state?
At the moment I use a manual workaround. From VirtualBox.xml I remove all <Harddisk> entries under <MediaRegistry\Harddisks> and restart the PC.
Generally I do all commands via VBoxManage. I use an own storage location for the image files (vmdk, vhd). But when I delete a VM the used image remains in list of harddisks, "VBoxManage.exe list hdds" shows still the unregistered image.
I suppose this could be the reason for the message "Cannot register the hard disk because a hard disk with UUID already exists".
Create a VM is done as follows:
VBoxManage.exe createvm --register --name "%VM_NAME%" --ostype Debian_64
VBoxManage.exe storageattach "%VM_NAME%" --storagectl flash --port 0 --device 0 --type hdd --medium "%VM_IMAGE%" --setuuid ""
Delete a VM is done as follows (the image should not be deleted):
VBoxManage.exe storageattach "%VM_NAME%" --storagectl flash --port 0 --device 0 --type hdd --medium none
VBoxManage.exe closemedium disk "%VM_IMAGE%"
VBoxManage.exe unregistervm "%VM_NAME%" --delete
For one image (eg. C:\xyz.vmdk) the Create-VM/Delete-VM is done multiple times, eg:
Create-VM with C:xyz.vmdk, start this VM, Delete-VM and then again Create-VM with C:xyz.vmdk, start this VM, Delete-VM.
When using the GUI "Oracle VM VirtualBox Manager / Manager for virtual media" with the "Remove" button the image disappears from output of "VBoxManage list hdds" output.
Generally it is no problem if the unregistered images remain in harddisk registry (output of VBoxManage list hdd) but as I mentioned sometimes my VirtualBox is fully damaged with the "harddisk UUID conflict".
I tried different VirtualBox version (6.1.20, 6.1.22, 6.1.24, 6.1.28).