Hi,
We have both .VBox and .VDI files in the folder copied as part of VirtualBox Image and available in the folder in windows Host.
We would like to register the VM (using the existing .Vbox file) and add the virtual media manager (using the existing .vdi file) by using VBoxManage.exe command line.
This one was working through VirtualBox Manager UI by adding .VDI as virtual media and add virtual machine using .Vbox file. However we wanted to acheive the same through the command line.
#VBoxManage registervm /full/path/to/the/.vbox/file
The above comand fails as it was looking for UUID of VDI defined in the .vbox file
#VBoxManage" storageattach <vm name> --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "c:\screening\screening-disk1.vdi"
The above command requires the vmname and it is not available as the register VM fails
Would be good if you can provide the command line options to attach the VDI first (without specifying VM) and register VM .
Looking forward your help.
Thanks in advance.
Regards
Saran
How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
Your question doesn't really make sense. If the VDI was already part of the VM then there should be no need to attach it again.
You register a VM on a new host by double clicking the .vbox file. Or, you can run the VirtualBox manager and use Machine|Add....
You register a VM on a new host by double clicking the .vbox file. Or, you can run the VirtualBox manager and use Machine|Add....
Please quote the exact error message. Guessing at the error: VirtualBox will always complain about missing media, and you can't fix that error by attaching new media, it can only be fixed by providing the missing media with the expected UUID, on the registered path, or by detaching the media.#VBoxManage registervm /full/path/to/the/.vbox/file
The above comand fails as it was looking for UUID of VDI defined in the .vbox file
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
Hi,
Thanks much for your reply. I think you have misunderstood the question, when I add through VirtualBox UI (first the VDI file through virtual media option) and Add the VM (vbox file in same folder) it works perfectly fine.
However the issue arise, when i tried to registet the VM pointing to .vbox file. Please note that .VDI file also in the same folder, but still the i got UUID is not found.
The following error is the one displayed when i tried to do so.
Thanks
Saran
Thanks much for your reply. I think you have misunderstood the question, when I add through VirtualBox UI (first the VDI file through virtual media option) and Add the VM (vbox file in same folder) it works perfectly fine.
However the issue arise, when i tried to registet the VM pointing to .vbox file. Please note that .VDI file also in the same folder, but still the i got UUID is not found.
The following error is the one displayed when i tried to do so.
Hope it clears and looking forward your response.C:\PROGRA~1\Oracle\VirtualBox>VBoxManage registervm C:\saran\Wealthx_Screening_Installer\screening\screening.vbox
VBoxManage.exe: error: Could not find an open hard disk with UUID {183ba78c-bc22-4ea6-a388-f313fe13e054}
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee IUnknown
VBoxManage.exe: error: Context: "OpenMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 86 of file VBoxManageMisc.cpp
Thanks
Saran
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
I admit that I've never noticed this before. I assumed that "registervm" would have the same function as "Machine|Add...", and I don't immediately see why it doesn't: perhaps it is simply that "registervm" is more low level than the UI function.User Manual section 8.6 wrote: The registervm command enables you to import a virtual machine definition in an XML file into Oracle VM VirtualBox. The machine must not conflict with one already registered in Oracle VM VirtualBox and it may not have any hard or removable disks attached. It is advisable to place the definition file in the machines folder before registering it.
I'm not entirely sure of the scope of the term "attached". Usable media in a VM must be both registered with the VM and attached to a controller. I'm not sure if the paragraph above implies that neither can be true in the registered .vbox file (*). Of course you must also add a controller to the VM, but I'd assume that can be done in advance.
(*) I don't see a separate "registermedia" command, so I assume that storageattach does that automatically.
-
- Posts: 4
- Joined: 24. Oct 2018, 22:00
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
I am having the same issue. Using the VirtualBox GUI we can easily add disk images before adding the VM itself. I am looking for the commandline parameter to do that.
I have a dualboot system with Linux and Windows, and I use Virtualbox to have the same virtual machines in both environments. If I create a VM on Windows, I have to register it when I go to Linux.
I also use differencing disks. The only way to successfully add an existing VM in that situation is to first add the disks and snapshots using the Media Manager, and then add the VMs. I would like to make a script to do that for me. But that seems to be impossible without having a command line version of adding disk images.
I have a dualboot system with Linux and Windows, and I use Virtualbox to have the same virtual machines in both environments. If I create a VM on Windows, I have to register it when I go to Linux.
I also use differencing disks. The only way to successfully add an existing VM in that situation is to first add the disks and snapshots using the Media Manager, and then add the VMs. I would like to make a script to do that for me. But that seems to be impossible without having a command line version of adding disk images.
-
- Posts: 4
- Joined: 24. Oct 2018, 22:00
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
I found an important step to the solution:
Virtualbox saves its repository in an XML file.
On my Linux system it is in /home/<user>/.config/VirtualBox/VirtualBox.xml
On Windows it is in c:\Users\<user>\.VirtualBox\VirtualBox.xml
There is a statement in the file telling that you shouldn't change this file manually, but in this case we have to.
From my Linux system I can access the Windows file with /mnt/c/Users/... etc.
From Windows we cannot see the Linux home folder, but this can be solved by moving the file to a location on our Windows partition, and then use a symlink to it in the home folder.
Now we have to copy two XML collections from one file the other: the <MachineRegistry> and the <MediaRegistry>
After copying these lines we still have to do a global replace to change the folder names from D:/VM/ to /mnt/d/VM/ or vice versa.
I tested this by doing these steps manually. It works perfectly!!
Now we have to find a way to automate it. I think making a bash script for my Linux system is doable. A cmd file for Windows might be difficult, though. Maybe Powershell would work. Or a c# program in .Net Core. That will work cross platform.
There is still work to do, but at least we have a starting point.
Virtualbox saves its repository in an XML file.
On my Linux system it is in /home/<user>/.config/VirtualBox/VirtualBox.xml
On Windows it is in c:\Users\<user>\.VirtualBox\VirtualBox.xml
There is a statement in the file telling that you shouldn't change this file manually, but in this case we have to.
From my Linux system I can access the Windows file with /mnt/c/Users/... etc.
From Windows we cannot see the Linux home folder, but this can be solved by moving the file to a location on our Windows partition, and then use a symlink to it in the home folder.
Now we have to copy two XML collections from one file the other: the <MachineRegistry> and the <MediaRegistry>
Code: Select all
<MachineRegistry>
<MachineEntry uuid="{509ec0ef-5dc4-4885-a8ec-6bb1d838649c}" src="D:/VM/basewin10_1551435931720_92059/basewin10_1551435931720_92059.vbox"/>
<MachineEntry uuid="{bc4c8357-98e6-408f-b2b1-de59a04fc414}" src="D:/VM/basewin10office/basewin10office.vbox"/>
...
</MachineRegistry>
<MediaRegistry>
<HardDisks>
<HardDisk uuid="{92cb08ad-ff8b-466b-84e3-2db08b26a042}" location="D:/VM/basewin10_1551435931720_92059/box-disk001.vmdk" format="VMDK" type="Normal">
<HardDisk uuid="{b38ed639-ac27-4c78-bd22-28294da0641c}" location="D:/VM/basewin10_1551435931720_92059/Snapshots/{b38ed639-ac27-4c78-bd22-28294da0641c}.vmdk" format="VMDK"/>
<HardDisk uuid="{eb698143-b20a-405e-b915-e93c13341b84}" location="D:/VM/basewin10office/Snapshots/{eb698143-b20a-405e-b915-e93c13341b84}.vmdk" format="VMDK">
<HardDisk uuid="{f6553a23-94ce-427b-97b2-6e33ce0ad996}" location="D:/VM/basewin10office/Snapshots/{f6553a23-94ce-427b-97b2-6e33ce0ad996}.vmdk" format="VMDK"/>
</HardDisk>
....
</HardDisks>
</MediaRegistry>
I tested this by doing these steps manually. It works perfectly!!
Now we have to find a way to automate it. I think making a bash script for my Linux system is doable. A cmd file for Windows might be difficult, though. Maybe Powershell would work. Or a c# program in .Net Core. That will work cross platform.
There is still work to do, but at least we have a starting point.
-
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
No, actually what you found is a known bug.janvanveldhuizen wrote:I found an important step to the solution:
You imported the VMs from somewhere, you didn't create them yourself, that's the only time you get bitten by that bug. During the import, the <MediaRegistry> section of the imported VM, instead of going into the .vbox for the VM, it ends up in the global registry, "VirtualBox.xml". In theory this section should end with the .vbox file, but it doesn't.
It was discovered as part of the analysis for ticket #17908: Optional entries in the <MediaRegistry> section may prevent VM registration and it cost me 11 VM definitions gone AWOL. The issue has been addressed already, but there's not a lot of things that can be done for existing setups, except manual intervention.
What you would need to do in theory, and I'm telling you this because you seem to know your way around an XML file, is to "move" the appropriate sections from the global repository to the individual VM's .vbox file. If you could attach your "VirtualBox.xml" and the "basewin10_1551435931720_92059.vbox", I could show you what needs to be done and how.
As for your other issue of having multiple VMs accessible by several hosts, I'm doing exactly that and I have some pointers if you want. But that should be the topic for a new thread that you may wish to open...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Re: How to register VM(from .vbox) and Add virtual media manager (.vdi) using command line
Aha... okay...
That explains a lot.
I am not importing them, but I use vagrant. I assume vagrant uses the import feature behind the scenes.
I had a bash script for Linux, and a cmd file for Windows, that iterates through my vagrant and VM folders to register the VMs that I made in the other OS. And to unregister the ones that are removed and became inaccessible in the meantime.
I was wondering why that didn't work anymore since some time. Since then I am adding the disk images manually before registering the VMs themselves. Very annoying. So I was happy to find the workaround.
The files are attached.
That explains a lot.
I am not importing them, but I use vagrant. I assume vagrant uses the import feature behind the scenes.
I had a bash script for Linux, and a cmd file for Windows, that iterates through my vagrant and VM folders to register the VMs that I made in the other OS. And to unregister the ones that are removed and became inaccessible in the meantime.
I was wondering why that didn't work anymore since some time. Since then I am adding the disk images manually before registering the VMs themselves. Very annoying. So I was happy to find the workaround.
The files are attached.
- Attachments
-
- basewin10_1551435931720_92059.vbox.txt
- vbox attachments appear not be allowed...
- (13.26 KiB) Downloaded 78 times
-
- VirtualBox.xml
- (8.34 KiB) Downloaded 72 times