VirtualBox Cannot register the hard disk already exists
VirtualboxVirtualbox Problem Overview
I created a virtual disk file VM_1_Ubuntu.vdi. Then I moved it into another folder. I tried to update VM settings (right click on virtual machine -> settings -> Storage -> Controller SATA tab, VM_1_Ubuntu.vdi path). I wanted to set a new path.
It says Cannot register the hard disk already exists
Virtualbox Solutions
Solution 1 - Virtualbox
I found a solution
File -> Virtual Media Manager -> Removed existing images (note, I removed them only from the registry).
I followed these steps.
After that I could update the path in the VM settings.
Solution 2 - Virtualbox
It's possible to change the UUID on the VDI file using the command:
VBoxManage internalcommands sethduuid <file.vdi>
It seems this command assigns a new "random" UUID to the file. No much documentation on it, though.
Solution 3 - Virtualbox
- Select File from Oracle VM VirtualBox Manager
- Virtual Media Manager
- Remove the file (highlighted yellow) from Hard disks tab.
Solution 4 - Virtualbox
Here is the solution for that find the UUID of box
vboxmanage list hdds
then delete by
vboxmanage closemedium disk <uuid> --delete
Solution 5 - Virtualbox
If there is no possibility to remove or change path to a hard disc file using Virtual Media Manager (in my case) then:
- Open '.vbox' and '.vbox-prev' (if exist) files in any text editor.
- Edit 'location' attribute of the element 'HardDisk' to your path, for example: "d:/VM/VirtualBox/Win10/Win10.vmdk" (screenshot).
Solution 6 - Virtualbox
In some cases first your need to Release, then Remove and Re-add via Virtual Media Manager
Solution 7 - Virtualbox
I really appreciate the suggestions here. The Impaler's and Oleg's comments helped me to piece my solution together.
Use the VBoxManage CLI. There's a modifymedium command with a --setlocation
option.
I suggest opening the VBox GUI (on VM VirtualBox Manager 6.0)
- select "Virtual Media Manager" (I used the File menu)
- select the "Information" button for the disk giving you this error
- copy the UUID
Note: I removed the controller from the "Storage" setting before the next step. - open your command prompt and navigate to the location of the .vdi file
It's a good idea to type VBoxMange to see a list of options, but this is the command to run:
VBoxManage modifymedium
[insert medium type here] [UUID] --setlocation
[full path to .vdi file]
Finally, reattach the controller to any VM--preferably the one you'd like to fix.
Solution 8 - Virtualbox
1 - Open the files '.vbox' and '.vbox-prev' (if exist) files in any text editor and replace the first character of HardDisk uuid (take note to revert this change on step 6)
Example: nano /home/virtualbox/WindowsServer/WindowsServer.vbox
Change:
<HardDisks>
<HardDisk uuid="{3ebaa9b6-8318-4b81-b853-8f30dd278bdc}" location="/home/virtualbox/WindowsServer/WindowsServer.vdi" format="VDI" type="Normal"/>
To:
<HardDisks>
<HardDisk uuid="{2ebaa9b6-8318-4b81-b853-8f30dd278bdc}" location="/home/virtualbox/WindowsServer/WindowsServer.vdi" format="VDI" type="Normal"/>
2 - Reboot machine
4 - Stop Virtual Machine (if started)
5 - On terminal:
su vbox
cd /home/virtualbox/WindowsServer/
VBoxManage modifyhd WindowsServer.vdi --resize SIZE
exit
exit
change SIZE for a number in Megabytes, example 80000 (80GB)
6 - Open again the files '.vbox' and '.vbox-prev' (if exist) files in any text editor and replace the first character of HardDisk uuid whith the original value
Example: nano /home/virtualbox/WindowsServer/WindowsServer.vbox
Change:
<HardDisks>
<HardDisk uuid="{2ebaa9b6-8318-4b81-b853-8f30dd278bdc}" location="/home/virtualbox/WindowsServer/WindowsServer.vdi" format="VDI" type="Normal"/>
To:
<HardDisks>
<HardDisk uuid="{3ebaa9b6-8318-4b81-b853-8f30dd278bdc}" location="/home/virtualbox/WindowsServer/WindowsServer.vdi" format="VDI" type="Normal"/>
7 - Reboot machine
Solution 9 - Virtualbox
The solution that worked for me is as follows:
- Make sure VirtualBox Manager is not running.
- Back up the files
~\.VirtualBox\VirtualBox.xml
and~\.VirtualBox\VirtualBox.xml-prev
. - Edit these files to modify the
<HardDisks>...</HardDisks>
section to remove the duplicate entry of<HardDisk />
. - Now run VirtualBox Manager.
Example:
<HardDisks>
<HardDisk uuid="{38f266bd-0959-4caf-a0de-27ac9d52e3663}" location="~/VirtualBox VMs/VM1/box-disk001.vmdk" format="VMDK" type="Normal"/>
<HardDisk uuid="{a6708d79-7393-4d96-89da-2539f75c5465e}" location="~/VirtualBox VMs/VM2/box-disk001.vmdk" format="VMDK" type="Normal"/>
<HardDisk uuid="{bdce5d4e-9a1c-4f57-acfd-e2acfc8920552}" location="~/VirtualBox VMs/VM2/box-disk001.vmdk" format="VMDK" type="Normal"/>
</HardDisks>
Note in the above fragment that the last two entries refer to the same VM but have different uuid's. One of them is invalid and should be removed. Which one is invalid can be found out by hit and trial -- first remove the second entry and try; if it doesn't work, remove the third entry.
Solution 10 - Virtualbox
After struggling for many days finally found a solution that works perfectly.
Mac OS open ~/Library folder (in your home directory) and delete the VirtulBox folder. This will remove all configurations and you can start the virtual box again!
Others look for .virtualbox folder in your home directory. Remove it and open VirtualBox should solve your issue.
Cheers!!