Tuesday, 30 October 2012

How-To: Resolve Attached Media Conflicts in VirtualBox

Here's another corker of an error in Oracle VirtualBox. First, you think your virtual machine is broken. Second you wonder how your storage tree got messed up.

When you move Virtual machine files around, revert machine Snapshots and update attached strage, you can get something like this:

Failed to open virtual machine located in /vm_data/machines/Quetzal-VM/Quetzal-VM.vbox.

Cannot register the DVD image '/usr/share/virtualbox/VBoxGuestAdditions.iso' {20f4b244-eb29-4082-ac34-4acf6ccb4904} because a CD/DVD image '/usr/share/virtualbox/VBoxGuestAdditions.iso' with UUID {62ebaac7-ba6d-4d7d-876b-362642de4c1b} already exists.


Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {3b2f08eb-b810-4715-bee0-bb06b9880ad2}


Which all looks a bit scary. It isn't.

While upgrading VirtualBox to 4.2, it had properly updated the .iso image of Guest Additions. Firing up  a virtual machine last used under 4.1, with the 4.1 Guest Additions attached under the media tree, it then rightly complains about the conflict; two .iso's, same name, different disk ID's. VirtualBox does a double-take at this sleight of hand.

The answer? Close the VM. First make sure the guest is shut down (not saved state).Open the Preferences, go to Media Manager. See if you can release and remove the old VBoxGuestAdditions.iso from there.

If that doesn't work, you need to edit a bit of XML. Again, make sure the guest is shut down (not saved state) and the VirtualBox program itself is not running. In the VM's folder is the settings file for that VM  a .vbox. You need to look for the VM by name in your designated machines folder. If the guest was created with version 4.0 or later, the file will be located in your home folder under VirtualBox VMs then the name of the guest, or wherever you specified in Preferences if you changed it. Make a backup of this file somewhere safe before you start editing.

In the .vbox file, you'll be looking for the attached media section, something like:

<DVDImages>
<Image uuid="{0fe1ba24-f623-405c-a7a9-8c157c9b0520}" location="/usr/share/virtualbox/VBoxGuestAdditions.iso"/>
</DVDImages>

Then edit the file and remove the line containing the offending image and UUID, leaving the opening and closing section tags <DVDImages> and </DVDImages> tags in place. In my case, editing from this:

      <DVDImages>
        <Image uuid="{20f4b244-eb29-4082-ac34-4acf6ccb4904}" location="/usr/share/virtualbox/VBoxGuestAdditions.iso"/>
        <Image uuid="{4cac70c8-689d-4e2c-8b2f-4e4b21c2cdcd}" location="/vm_data/machines/software/iso/quantal-desktop-i386.iso"/>
      </DVDImages>

to this:

<DVDImages>
</DVDImages>

Save the file. You should then be able to start the Guest VM and attach any media the normal way. RC

26 comments:

  1. Robert von Knobloch28 December 2012 10:49

    Thank you, worked well for me under OpenSuse 12.2

    ReplyDelete
  2. Great tip. This helped me out no end!

    Thanks again.

    Steve

    ReplyDelete
  3. Awesome it worked ..
    Thank you ...

    ReplyDelete
  4. ..that helped me a lot. I tried a couple of days before without luck. Thank you :-))

    ReplyDelete
  5. Thank you. It worked.

    ReplyDelete
  6. Thank you a lot! :)

    ReplyDelete
  7. Best answer...
    thankss

    ReplyDelete
  8. You. You. Yes. Thank you.

    ReplyDelete
  9. Thanks so much!

    ReplyDelete
  10. Great!, thank you very much!

    ReplyDelete
  11. Awesome!
    I frequently reload my system and this allows me to double-click the vbox file to add it back to the VirtualBox console.

    Thanks!

    ReplyDelete
  12. You saved my day! Was googling the solution for quite some time...

    ReplyDelete
  13. Great tip, but one thing to note...I kept on getting a pop-up box to say that it couldn't mount the guest additions and asking if you wanted to force a mount, then bizarrely offering an unmounts button. After some investigation I found out that this message box meant that guest additions iso WAS ALREADY mounted, so the message box could actually be ignored.

    ReplyDelete
  14. Also useful to note that if you're simply in need of an immediate solution (and aren't too caught up on the vm configuration), just build a new machine and mount the old VDI...

    ReplyDelete
  15. Anon: that's also true. A bog-standard VM configuration is often quicker to recreate and re-use the disk image.

    ReplyDelete
  16. i worked fine!.. thnks a lot!!!

    ReplyDelete
  17. "First make sure the guest is shut down (not saved state)"
    If I can't load the VM (ie. it's already in saved state) how can I shut it down?

    ReplyDelete
  18. You saved me a day of work :)

    ReplyDelete
  19. Me, I'm getting:

    Result Code: E_INVALIDARG (0x80070057)
    Component: VirtualBox
    Interface: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}

    .. but, IDK - whether it's because I'd updated teh Oracle VM and/or whether it's because both, the new won and the old image that I had - are both of the same (exact) name, meh.

    (Tryin' 2 figure it out, ATM, but it's just a headache. :))

    ReplyDelete
  20. Err, can't edit my previous comment: "Your comment will be visible after approval."

    ^^ By "both", I meant my old Xubuntu virtual machine and a new one that I created.. Since there's an update, of Ubuntu, just released. =)

    ReplyDelete
  21. Nostromov: yep, I understood; duplicate names of anything in VBox give it headaches, so no surprise. You have to de-register old instances before you can re-use a name.

    Top tips when doing any config changes; always update VBox, matching extensions and Guest Additions before you start changing things in Media Manager. Make sure VM's are shut down and not paused or suspended.

    ReplyDelete

At least try to be nice, it won't kill you...