Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using VirtualBox hosted on Windows 7 and the physical hard drive that one of my VM's VDI file was on got completely borked and no longer exists.

The problem is that now I can delete neither virtual hard drive nor VM since the attempt to delete the VDI file gives me an error stating that VirtualBox can't find the file and of course, I can't delete the VM without first releasing (or deleting) the VDI file that that machine was using.

UPDATE: Note that I've also removed all storage attachments and the snapshots cannot be deleted for the same reason--it can't find the files (because of the non-existent hard drive).

Does anyone know of a solution?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Delete your VM xml files on Hard Disk. They are located by default in C:\Users\YOUR_NAME\.VirtualBox\Machines.

After deleting, you'll still receive strange erros messages in Virtualbox. This is because some info about your vms are inside C:\Users\YOUR_NAME\.VirtualBox\VirtualBox.xml.

If you don't mind losing some global configuration in your VirtualBox, just delete this file. Virtualbox will create another if it doesn't exist.

If you just want to remove a specific VM, you have to edit Virtualbox.xml in some xml editor (notepad is fine. notepad++ is better since it has syntax highlighting).

You'll find these fields:

<MachineRegistry>
  <MachineEntry uuid="UUID" src="Machines\MACHINE_NAME\MACHINE_NAME.xml"/>
</MachineRegistry>
<MediaRegistry>
  <HardDisks>
    <HardDisk uuid="UUID" location="HardDisks\DISC_NAME.vdi" format="VDI" type="Normal"/>
  </HardDisks>
  <DVDImages>
    <Image uuid="UUID" location="C:\IMAGES\IMAGE.iso"/>
  </DVDImages>
  <FloppyImages/>
</MediaRegistry>

Remove the MachineEntry from the desired VM. If you just have one VM and want to remove everything, just leave the tags empty. For example:

<MachineRegistry/>
<MediaRegistry>
  <HardDisks/>
  <DVDImages/>
  <FloppyImages/>
</MediaRegistry>

...and you're done. I just tested everythong here and it works flawlessly. If you want to avoid problems, backup your xml configuration files from VirtualBox and specific VMs.

(I didn't mention about snapshots, but I believe it's the same principle.)

share|improve this answer
    
You don't need to remove snapshots as they are contained in the C:\...\Machines\MyVM directory. –  gvkv Jun 27 '10 at 22:40

First, delete any snapshots of that Virtual Machine. Then open the settings of the Virtual Machine, go to Storage tab, right click on the vdi file under IDE Controller and click on Remove Attachment. Now you should be able to remove the VDI from the Virtual Media Manager.

enter image description here

share|improve this answer
    
I can't remove the snapshots and I've already removed the controllers. –  gvkv Jun 27 '10 at 19:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.