Clean up intentionally deleted Virtualbox drives manually

I deleted two virtual disks from a VirtualBox VM the wrong way. I removed them from the guest config, but forgot to remove them from the media list, and deleted the files and directories from the filesystem, so I see the disks as errored in the media list. They have associated snapshots, so I get errors about them being in use. If I try to delete the associated snapshots via the GUI or vboxmanage I get this error message:

VBoxManage.exe: error: VD: error VERR_PATH_NOT_FOUND opening image file [location]

Of course the snapshots are also gone (these were old vmdk files I mounted, so the snapshots may not even be real). How do I manually remove these ghost entries from my VirtualBox config? I suspect there's a config file or a registry entry, but I'm not sure where to look.

1

3 Answers

Hope this helps somebody.

cat ~/.config/VirtualBox/VirtualBox.xml | grep your_roguedisk.vdi

Grab the output of the UUID.

$ vboxmanage closemedium disk "{d89ef84a-d754-4da2-b2a1-cc37063d0c6d}" --delete

The error is like the following screenshot:

VirtualBox_File_Not_Found_Error

VERR_PATH_NOT_FOUND means the provided file path is not valid. After any operation with VBoxManage, VirtualBox saves the file path in Global Configuration file. The file is a XML format file. VirtualBox maintains global configuration data in the following directory:

  • Linux and Oracle Solaris: $HOME/.config/VirtualBox/VirtualBox.xml
  • Windows: %UserProfile%\.VirtualBox\VirtualBox.xml or C:\Users\UserName\.VirtualBox\VirtualBox.xml
  • Mac OS X: $HOME/Library/VirtualBox/VirtualBox.xml

That file contains configuration of every Virtual Machines. So back it up before edit. Open that VirtualBox.xml file in any text editor. Find the file path that you want to delete. Generally the path resides in <HardDisk/> tag. For example, the format will be like this:

<HardDisks> <HardDisk uuid="{3761d018-e224-45d4-aa61-764d2c408712}" location="F:/test.VHD" format="VHD" type="Normal"/> <HardDisk uuid="{9f4f1f1c-f4c9-4773-a0b3-f0c52f699142}" location="F:/test.VMDK" format="vmdk" type="Normal"/>
</HardDisks>

Remove the full tag line otherwise VBox shows error. That's why backup that file before doing any change. For further details, see VirtualBox Docs: 10.1.3. Global Configuration Data.

3

Inspired by the first response, which did not work, I found the solution. The solution is to stop VirtualBox, then go into the directory for the (or each) individual VMs that reference the disk images in question, edit the .vbox file for the VM, delete the HardDisk entries (including snapshots), and then start up VirtualBox again. The media manager will show no entries for those disks.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like