26th Jun2014
Author: Gyro

VirtualBox – moving a VDI file and re-linking it to the Guest

virtualbox

Today I decided to move my vdi files to another partition.
So, I moved them and then started the Oracle VM VirtuaBox Manager to re-link the vdi files to the respective guest.First, I opened the settings of each Virtual Machine and deleted the "old" hard disk under "Storage".Then I clicked on "Add Attachment", selected "Add Hard Disk" and "Choose existing disk", and then selected the vdi file.

Next came a very strange error:

The Problem

Cannot register the hard disk ‘FULL PATH TO NEW LOCATION OF VDI' with UUID {UUID OF THE VDI} because a hard disk ‘FULL PATH TO OLD LOCATION OF VDI' with UUID {UUID OF THE VDI} already exists in the media registry (‘/home/user/.VirtualBox/VirtualBox.xml').

This confused me pretty good, as I knew for a fact that I moved the vdi, so it did not exist at the old location anymore. I also had no clue what this media registry was supposed to be, and before opening that xml file and messing around with it, I decided to see if others had this issue before.

After a bit of google-ing, I found the solution in the VirtualBox forum:

Even though the thread was started on 2. Mar 2009, 16:43, some kind soul decided to register to the forum to make one single post to the forum in this thread on 21. Dec 2012, 22:00 (Christmas spirit?) with the simple solution to this problem.

Hi there,

I had the same UUID problem and a very easy fix worked for me. I went File>virtual media manager. I found the vdi file that was giving me issues. Selected it and removed (though it was showing up as inaccessible). Then started the VM again and selected the file from my local hard-disk. That was it!
Hope this works for you too. :)
Om

So, to summarize with a bit more clarity:

The Solution

1. Open the Oracle VM VirtuaBox Manager
     Click on File -> Virtual Media Manager (or Ctrl+D)
2. Delete the hard disk entry in question (select and press "Del" on keyboard)
3. Open "Settings" of the Virtual Machine, go to "Storage", click "Add Attachment", select "Add Hard Disk" and "Choose existing disk", then selected the vdi file and you are done.

Enjoy :)

276360

Keep Me Going
Your Name / Website:
Did you like my post? Buy me a Bitcoffee! 14JX52Li7zTKbyQv2omw4tvu6Bi1KzfHNW



55 Responses to “VirtualBox – moving a VDI file and re-linking it to the Guest”

  • Dimitri

    Thanks!!!!

  • Gerardo Ariel

    Man, thanks a lot for this! It was so easy, and there were so many weird solutions on the net that are nonsenses.
    Thankfully I kept searching and found your post! Cheers and good luck!

  • Gary Heard

    Can only say thanks, I’d trawled that thread but missed what you picked up.

    Thanks for finding it and for putting it up there

  • Walter

    Unfortunately the suggested procedure did not work for me as the “Remove” option in the Virtual Media Manager was grayed out. The same applies to the “Release” option.

    • Gyro

      Normally, “remove” is only grayed out when the drive is still attached to a guest, and “release” in grayed out when a disk is no longer attached to a guest, but I have never seen both of them grayed out at the same timeh…

      Which Host OS do you use?

      Looking at the terminal commands, you could just do: ~$ VBoxManage storagectl uuid-of-the-drive --remove

      That’s 2 dashes infront of the ‘remove’, I need to fix the way that is displayed… actually I need a new theme, as this one isn’t even mobile friendly…

      To get the uuid of the drive you want to remove: ~$ VBoxManage list hdds

      You will see something like this:

      UUID: e294fc8b-7414-48be-bef4-80e1dc76edcf
      Parent UUID: base
      State: created
      Type: normal (base)
      Location: /home/gyro/VirtualBox VMs/Android-x86/Android-x86.vdi
      Storage format: VDI
      Capacity: 59578 MBytes

      • Doing ” VBoxManage storagectl uuid-of-the-drive –remove” brings me “Syntax error: Too few parameters” message. Why?

        • Gyro

          Hi, did you actually provide the UUID? Also, did you use double dashes? (--remove)

      • bandgooi

        “Syntax error: Too few parameters”

        • Gyro

          Hi, did you actually provide the UUID? Also, did you use double dashes? (--remove)

          • Same result here: storagectl requires an extra parameter “–name “. I think that’s probably the wrong command, since Help says storagectl removes a *storage controller*. Maybe ‘VBoxManage closemedium disk ‘, with an optional extra –delete if the file exists and you want the file deleted as well as its record in the Virtual Media Manager.

            I was able to delete from File | Virtual Media Manager…, so couldn’t try this.

            Many thanks!!

          • Gyro

            As you have already figured out, WP has taken two dashes and made a single long one from it. I will have to revise my posts and add a proper “code” tag that I can use, so it won’t get formatted by WP.

          • Both –name and –delete parameters should start with a double dash. Sorry, forum is auto-converting them to an en-dash, and I can’t see a link here to tell me the correct format. Maybe --name and --delete? (That was . . . without the extra spaces :D )

          • Goodness, WordPress really does love to mess with my comments. To get the nice formatting, enclose things with double dashes etc. in HTML code tags.

          • Gyro

            I haven’t updates the site in a couple of years. Your comment makes me want to try out a new theme and a better editor for comments now… :)

  • Frenk

    Thanks!!!

  • javad

    Thanks man it helped….

    • Gyro

      Thank you for your comment, it makes my day to know I was able to help someone :)

  • antony

    THANKS!!!!!!!

  • Klerio Silveira

    Thanks man. You helped me. All fixed.

  • Fernando H

    Wow. So many strange workarounds and somewhat complicated methods on the internet, and this worked. Thanks!

  • Thanx a lot, you rocks!

  • ommit

    Worked like a charm. Thank you.

  • Edy

    Thanks a lot, very nice and simple solution

  • Jeremy

    I had this problem many many months ago and found a command line solution that fixed the problem (I recall changing/assigning a new UUID to my storage file). However I forgot what I did.

    THANKFULLY, i found this simply solution. Thanks again.

  • Eslam MOSTAFA

    Thanks ver much ,you really help me

  • Leo

    Man, this is so simple and nobody knows that!! Thanks for sharing! The only post that helped me! Thanks!!

  • viki

    thanks…saved hours of trouble

  • Sujith John

    Thank you !!!!!!!!!!! helped ! been trying to edit the .xml file and went all around the place.

    Thanks again!!

  • Nour Alhadi

    I can surely say…
    Many thanks to you my friend
    your the best online :-)

    • Gyro

      I think the best would deserve a coffee. I didn’t get one, so… :)

      Thanks for the kind words and making my day.

  • Road

    THANKS!!!!

  • Chandra

    Thanks It worked for me..!!

  • gg

    I love you.

  • Nabeel Bukhari

    Thanks a lot, I found weird solutions for same in other blogs. It was quite simple.

  • Qasim AlQari

    Great Job ..
    It worked for me ..

  • JOSHI

    Hi Gyro,

    Thanks for posting it. Solution worked perfectly for me. Have a great weekend.

  • Disk Crasher

    Too easy, can’t believe I didn’t try this myself. Thanks.

  • David

    Add one more to the thanks!

  • Eric Duncan

    Holy crap, that was simple.

    As so many else have echo’d, all other solutions are inapt.

    Thank you!

  • Kumar

    Superb!

  • Ram

    Thanks !

  • IanMc

    Excellent advice, thanks very much.

    That saved me a bunch of time, thank you.

  • JoeCool

    Super helpful, thanks man!

  • Pierre

    Thank you so much for sharing!

  • I had a similar error. I had a VM in virtualbox, which was copied into a separate folder, when I powered it off. Now, I wanted to add it as a separate VM with a different name. However, I was seeing this UUID conflict. What I did :

    1) Created a new empty VM with the desired NAME.
    2) Located the new folder, where copy of the VM was there.
    3) Ran the commands to change the UUID for each disk-file (.vmdk or others) I had there : “C:\Program Files\Oracle\VirtualBox\vboxmanage.exe” internalcommands sethduuid disk1.vmdk
    (you have to be in the same directory as the disk files, to run this command. Easy, wherever you need the command window, SHIFT+Right-click > open command window here)
    4) I ran the above command 4 times for 4 disks I had in the folder. Each disk file got new UUID now.
    (make sure to remember / note the sequence of disk file numbering if there are many)
    5) Now, go into the settings of the empty VM, storage, add the disks in same sequence under SATA disks.
    6) That’s it ! Now could start my new VM without issues, as all the disks had new UUID without conflicts.

  • MrCris

    Thanks for helping me out! Keep it going

  • Ivan Terziev

    thanks you!

  • z4kk

    Thanks you are awesome
    best regards

  • bixiou

    YOU ROCK !

  • GatoSantos9

    Thanks!!!

  • Sreekant

    Thank you – It was such a simple solution, thankfully I came here :)

Leave a Reply

Your email address will not be published. Required fields are marked *

What is 14 + 3 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)