Re-register existing .vdi when host disk mount point changed

Discussions related to using VirtualBox on Linux hosts.
Post Reply
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re-register existing .vdi when host disk mount point changed

Post by el_gallo_azul »

That's my best attempt at a useful "Subject" within the available space.

I've been using a Windows XP.vdi for about a year. A couple of days ago, I mounted my (host) hard disk (on which the guest virtual hard disk resides) to a different mount point.

It has been easy to rectify most things that were broken during this change.

I tried to

VirtualBox Manager > Select guest > Settings > Storage > Select virtual hard disk > Change attributes (the location)

for the virtual disk, but was not able to. I can't remember exactly what the error was, but I think it was the same as the one I describe below.

I deleted that link to the disk using the '-' icon, and tried to

VirtualBox Manager > Select guest > Settings > Storage > Select controller (IDE) > select '+' icon for existing controller > Add Hard Disk > Choose existing disk > Choose the virtual hard drive file > Open

but that gives the error
Failed to open the hard disk file /mnt/InternalHDD/VirtualBox VMs/Windows XP/Windows XP.vdi.

Cannot register the hard disk '/mnt/InternalHDD/VirtualBox VMs/Windows XP/Windows XP.vdi' {2aae6354-384c-428e-b3b1-6cf286323eb7} because a hard disk '/media/el_gallo_azul/Storage/VirtualBox VMs/Windows XP/Windows XP.vdi' with UUID {2aae6354-384c-428e-b3b1-6cf286323eb7} already exists.

Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
The UUID {2aae6354-384c-428e-b3b1-6cf286323eb7} seems to me to be a VirtualBox one. As you can tell, my (host) hard disk which was at mount point

/media/el_gallo_azul/Storage/

is now at mount point

/mnt/InternalHDD/

and no other changes have been made.

How can I register this existing virtual hard disk to the same existing guest again?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Re-register existing .vdi when host disk mount point cha

Post by mpack »

A VDI is a disk image, useless on it's own. Just because it's a big file doesn't make it the only significant one.

You need to restore the entire VM folder from your backup to any convenient location - and ideally discard the stuff you've already messed with - and then it's the VM (i.e. the .vbox file) which needs to be re-registered using Machine|Add.
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re: Re-register existing .vdi when host disk mount point cha

Post by el_gallo_azul »

I'm afraid I don't really understand that.
You need to restore the entire VM folder from your backup to any convenient location - and ideally discard the stuff you've already messed with - and then it's the VM (i.e. the .vbox file) which needs to be re-registered using Machine|Add.
I haven't moved any of my applications from the SSD to the HDD.

For example, I see that there is still the folder "/home/el_gallo_azul/VirtualBox VMs/Windows XP", which contains "Windows XP.vbox".

I placed "Windows XP.vdi" on my HDD when I created it a year ago because I knew that it would see many write cycles.

1. What do you mean by "backup"?

2. What do you mean by "the stuff you've already messed with"?

3. If I try to Machine > Add... > Select "/home/el_gallo_azul/VirtualBox VMs/Windows XP/Windows XP.vbox", I get
Failed to open virtual machine located in /home/el_gallo_azul/VirtualBox VMs/Windows XP/Windows XP.vbox.

Trying to open a VM config '/home/el_gallo_azul/VirtualBox VMs/Windows XP/Windows XP.vbox' which has the same UUID as an existing virtual machine.

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Machine
Interface: IMachine {480cf695-2d8d-4256-9c7c-cce4184fa048}
Callee: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
Do I need to "Remove..." the machine and create it again, or is there some way that I can tell "Windows XP.vbox" where "Windows XP.vdi" is located now?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Re-register existing .vdi when host disk mount point cha

Post by mpack »

I see - so you moved the VM. I thought you were recovering from some kind of disk failure.

If you are happy with where the .vbox file is now then simply register it there, using Machine|Add... as I already said.

If the previous incarnation of the VM is still registered then you need to get rid of that first. Remove it if VBox will let you - be sure to say no when it asks if you want to delete the physical files (This would best have been done before you moved the VM).

If it won't let you remove the old VM then worst case is that you can simply delete the <userdoc>\.VirtualBox\VirtualBox.xml. That will cause it to lose it's memory of registered VMs and you can register them all again as above.
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re: Re-register existing .vdi when host disk mount point cha

Post by el_gallo_azul »

OK thanks.

Which file do you mean by "the VM"? Is that "Windows XP.vbox" or "Windows XP.vdi"?

I didn't actually move anything, but I did mount the disk upon which "Windows XP.vdi" resides to a different mount point, so that's kind of like moving it.

...

I just tried Remove... and then "Machine" > "Add...", but
Cannot create the machine folder Windows XP in the parent folder /home/el_gallo_azul/VirtualBox VMs.

This folder already exists and possibly belongs to another machine.
I then deleted the folder /home/el_gallo_azul/VirtualBox VMs which contained the folder Windows XP which contained the file "Windows XP.vbox".

I clicked "New", then allocated memory, and then selected the hard drive /mnt/InternalHDD/VirtualBox VMs/Windows XP/Windows XP.vdi, but
Failed to open the hard disk file /mnt/InternalHDD/VirtualBox VMs/Windows XP/Windows XP.vdi.

Cannot register the hard disk '/mnt/InternalHDD/VirtualBox VMs/Windows XP/Windows XP.vdi' {2aae6354-384c-428e-b3b1-6cf286323eb7} because a hard disk '/media/el_gallo_azul/Storage/VirtualBox VMs/Windows XP/Windows XP.vdi' with UUID {2aae6354-384c-428e-b3b1-6cf286323eb7} already exists.

Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Re-register existing .vdi when host disk mount point cha

Post by mpack »

What VirtualBox version are you using?

And did you read the FAQ: Moving a VM.
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re: Re-register existing .vdi when host disk mount point cha

Post by el_gallo_azul »

What VirtualBox version are you using?
VirtualBox Graphical User Interface Version 4.3.10_Ubuntu r93012
And did you read the FAQ: Moving a VM.
No I didn't read that page. I've read it now. It refers to "a VM" or "the VM" in several places. What does that mean?

1. Everything within a guest operating system's folder, which in turn is within the folder "VirtualBox VMs"?; or
2. "(guest operating system).vbox"?; or
3. "(guest operating system).vdi"?; or
4. Something else?

The "VirtualBox VMs" folder is created by VirtualBox within a user's home folder on Linux, which in my case is on an SSD. I placed my "Windows XP.vdi" on an internal HDD a year ago, in order to reduce the number of write cycles to the SSD.

I changed the mount point of my internal HDD a few days ago in order to reduce the number of (unnecessary) write cycles to the SSD from other applications that aren't VirtualBox, particularly BOINC.

My VirtualBox does not have any guest operating system listed since I removed Windows XP about 14 hours ago. I also deleted the folder "VirtualBox VMs" including its subfolders from my home folder.

For some reason, VirtualBox still thinks that
a hard disk '/media/el_gallo_azul/Storage/VirtualBox VMs/Windows XP/Windows XP.vdi' with UUID {2aae6354-384c-428e-b3b1-6cf286323eb7} already exists
, but in actual fact /media/el_gallo_azul/Storage/ doesn't exist since a few days ago.

Do you know how I can rectify that problem?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Re-register existing .vdi when host disk mount point cha

Post by mpack »

el_gallo_azul wrote:Do you know how I can rectify that problem?
I already told you that in my second post: delete the old VirtualBox.xml file, then reregister all your VMs.

Incidentally, it looks like you're using the Ubuntu fork of VirtualBox, which we don't support here.
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re: Re-register existing .vdi when host disk mount point cha

Post by el_gallo_azul »

OK thanks. I thought I'd look for that file yesterday, had forgotten the exact name (and forgot that you had mentioned it in your second post), remembered that it ended with ".xml", but didn't find it. Now I looked for "VirtualBox.xml", found it in

(Home)/.config/VirtualBox/

and deleted it. Yes, that's exactly what I was looking for.

Look, I'm sorry, but I'm afraid that I have one more question on this topic:

I'm trying to keep all VirtualBox stuff together in

/mnt/InternalHDD/VirtualBox VMs/

so I have placed my VirtualBox hard drives into that folder. For example, I have a folder called "/mnt/InternalHDD/VirtualBox VMs/Windows XP" in there which contains "Windows XP.vdi", and I want to keep all of my Windows XP stuff in that folder.

If I start VirtualBox, then

File > Preferences... > Default Machine Folder > Select /mnt/InternalHDD/VirtualBox VMs/

then try to create "Windows XP", I get the message
Cannot create the machine folder Windows XP in the parent folder /mnt/InternalHDD/VirtualBox VMs.

This folder already exists and possibly belongs to another machine.
How do I create the "Windows XP" virtual machine using the existing "Windows XP.vdi" such that all Windows XP ends up in "/mnt/InternalHDD/VirtualBox VMs/Windows XP"?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Re-register existing .vdi when host disk mount point cha

Post by mpack »

You can't create multiple VMs with the same name - the name is used as an ID. And as you've found, since the VM name is used as a folder name, VBox won't like that the folder exists.

You can however move VMs whereever you like on the host, after creation. See my previous link on how to move a VM. You can use use the grouping options of the GUI, however you'll have to experiment since I no longer use that feature since I don't like that it messes around with my physical folder structure.
el_gallo_azul
Posts: 38
Joined: 17. Oct 2013, 04:51

Re: Re-register existing .vdi when host disk mount point cha

Post by el_gallo_azul »

Thanks for getting back to me. I thought that might work, but didn't want to find out by trial-and-error.

What I did was:

1. Change the name of existing folder ".../VirtualBox VMs/Windows XP" by adding any text
2. In VirtualBox, create the new operating system without hard drive
3. Duplicate "Windows XP.vdi" to the new "Windows XP" folder created by VirtualBox - It was unnecessary to make a copy. I could have just moved it.
4. In VirtualBox, Settings > Storage > Choose IDE controller > "New" icon > "Add Hard Disk" > "Choose existing disk" > Select "Windows XP.vdi" > OK
5. Boot Windows XP to test

I have this operating system running again. Yay!
Post Reply