Virtualbox manager does not update vm file config

Discussions related to using VirtualBox on Linux hosts.
Post Reply
jcdole
Posts: 95
Joined: 3. May 2013, 18:25
Primary OS: openSUSE
VBox Version: PUEL
Guest OSses: WIN 7, WIN 10
Location: South west of france

Virtualbox manager does not update vm file config

Post by jcdole »

Hello.

1°) Create a linux vm named 'CD-RESCUE_VBOX' on a linux host as if you are creating a new linux vm
- Define the linux install cd (iso file)
- Define a small vdi file as destination of new vm 'CD-RESCUE_VBOX'
- Finish the config as usual
2°) Add a secondary hard disk ( vdi ) of a vm (named for instance 'DEFECTIVE_VM') to be repaired in term of operating system
- This vm 'DEFECTIVE_VM' is not registered and the vdi file 'DEFECTIVE_VM.vdi' never registered.
3°) start the install process
- In the install menu choose other, then choose rescue disk. The OS will not be installed.
- From the rescue terminal, do your repair.
- When finished shutdown
4°) Re-run Virtualbox manager and choose the vm 'CD-RESCUE_VBOX' you just used.
- In the storage menu, remove the secondary hard disk you just repaired ('DEFECTIVE_VM.vdi').
5°) Close every things.
6°) Open /home/user/VirtualBox VMs/CD-RESCUE_VBOX/CD-RESCUE_VBOX.vbox
- The reference to the file 'DEFECTIVE_VM.vdi' is still there.

Code: Select all

    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{4b2fd851-faa1-405a-93c6-c7a364894f63}" location="/data/virtual_LINUX_2/CD-RESCUE_VBOX/VDI/CD-RESCUE_VBOX.vdi" format="VDI" type="Normal"/>
        <[b][u]HardDisk uuid="{bd67490d-09cf-4809-92ef-33c1eb536f82}" location="/data/VBOX_REPAIR/DEFECTIVE_VM.vdi" format="VDI" type="Normal"[/u][/b]/>
      </HardDisks>
7°) Rename the vdi file from DEFECTIVE_VM.vdi to NEW_GOOD.vdi and move it to /virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi. So there is no more file '/data/VBOX_REPAIR/DEFECTIVE_VM.vdi'
8°) Create a new vm using the new existing file '/virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi'.
- Error

Code: Select all

Failed to open the disk image file /virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi.

Cannot register the hard disk '/virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi.' {bd67490d-09cf-4809-92ef-33c1eb536f82} because a hard disk '/data/VBOX_REPAIR/DEFECTIVE_VM.vdi' with UUID {bd67490d-09cf-4809-92ef-33c1eb536f82} already exists.

Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBoxWrap
Interface: IVirtualBox {d0a0163f-e254-4e5b-a1f2-011cf991c38d}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

The file /data/VBOX_REPAIR/DEFECTIVE_VM.vdi does not exists anymore because it has been moved to '/virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi.' but it is still referenced in the vbox file.

Any comment is welcome.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtualbox manager does not update vm file config

Post by fth0 »

jcdole wrote:2°) Add a secondary hard disk ( vdi ) of a vm (named for instance 'DEFECTIVE_VM') to be repaired in term of operating system
- This vm 'DEFECTIVE_VM' is not registered and the vdi file 'DEFECTIVE_VM.vdi' never registered.
Adding as a (secondary) hard disk automatically registers the DEFECTIVE_VM.vdi file. The MediaRegistry section is part of the registry, as the name indicates.
jcdole wrote:7°) Rename the vdi file from DEFECTIVE_VM.vdi to NEW_GOOD.vdi and move it to /virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi. So there is no more file '/data/VBOX_REPAIR/DEFECTIVE_VM.vdi'
Did you rename and move the file from within the VirtualBox Manager? ;)
jcdole
Posts: 95
Joined: 3. May 2013, 18:25
Primary OS: openSUSE
VBox Version: PUEL
Guest OSses: WIN 7, WIN 10
Location: South west of france

Re: Virtualbox manager does not update vm file config

Post by jcdole »

fth0 wrote:Adding as a (secondary) hard disk automatically registers the DEFECTIVE_VM.vdi file. The MediaRegistry section is part of the registry, as the name indicates.
This is not a problem and this is not the problem.
jcdole wrote: 4°) Re-run Virtualbox manager and choose the vm 'CD-RESCUE_VBOX' you just used.
- In the storage menu, remove the secondary hard disk you just repaired ('DEFECTIVE_VM.vdi').
5°) Close every things.
6°) Open /home/user/VirtualBox VMs/CD-RESCUE_VBOX/CD-RESCUE_VBOX.vbox
- The reference to the file 'DEFECTIVE_VM.vdi' is still there.
7°) Rename the vdi file from DEFECTIVE_VM.vdi to NEW_GOOD.vdi and move it to /virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi. So there is no more file '/data/VBOX_REPAIR/DEFECTIVE_VM.vdi'
8°) Create a new vm using the new existing file '/virtual_LINUX_1/LEAP_15.3_VM_2_FIRST_REBOOT/VDI/NEW_GOOD.vdi'.
- Error
In step 4 when you remove the hard disk, it should desapear from the vm config you edited.
fth0 wrote:Did you rename and move the file from within the VirtualBox Manager? .
No I just remove it.
So it should desapear from the config.

Thank you for helping.
Last edited by mpack on 5. May 2022, 12:14, edited 4 times in total.
Reason: Remove strange modifications to bbcode quotes.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtualbox manager does not update vm file config

Post by fth0 »

Generally speaking, I'd prefer a different method of repairing a virtual hard disk of a VM:

I'd simply boot the original VM from a GParted Live ISO (or another Linux Live ISO) and repair the virtual hard disk just in place. If the virtual hard disk was important, I'd have a backup anyway, to restore it to the previous state if anything went wrong during the repair.

When using your method instead, there are some pitfalls to avoid:

a) Background knowledge: When the first VirtualBox frontend (e.g. VirtualBox Manager, VBoxManage) or the first VirtualBox VM (e.g. VirtualBoxVM, VBoxHeadless) is started, it starts a process named VBoxSVC, which runs in the background until 5 seconds after the last VirtualBox frontend and the last VirtualBox VM has been terminated. After its start, the VBoxSVC process reads the (user-specific) global VirtualBox configuration file (VirtualBox.xml) and all VM configuration files (*.vbox) referenced therein into its internal memory, which can be considered as a Registry. While VBoxSVC is running, the files on disk have no significance, although they are partially updated sometimes. This is the major reason for the "DO NOT EDIT" warning inside those configuration files.

b) Because of a), make sure that the VBoxSVC process is not running before checking the contents of VirtualBox configuration files by hand. Otherwise, you may be looking at old data.

c) Because of a), do not modify, delete, move or rename VirtualBox configuration files outside of VirtualBox applications while the VBoxSVC process is running. Otherwise, you may be corrupting the VirtualBox Registry.
jcdole
Posts: 95
Joined: 3. May 2013, 18:25
Primary OS: openSUSE
VBox Version: PUEL
Guest OSses: WIN 7, WIN 10
Location: South west of france

Re: Virtualbox manager does not update vm file config

Post by jcdole »

fth0 wrote:Generally speaking, I'd prefer a different method of repairing a virtual hard disk of a VM:
I'd simply boot the original VM from a GParted Live ISO (or another Linux Live ISO) and repair the virtual hard disk just in place.
If you boot the original VM ( the one to be repaired, just in case if the vm boot ) you cannot modify the filesystem because the root partition is mounted and you cannot umount the root partition.
So you must run another VM and add the default machine as a simple additional hard drive.
I did not see another way to do so.
Anyway this is not my question.
fth0 wrote:When using your method instead, there are some pitfalls to avoid:
...
...
Of course.
Anyway this is not my question.

Now go back to my question : Virtualbox manager does not update vm file config

If you try to configure a new VM from an already registered vdi file you get an error liken :

Code: Select all

Cannot register the hard disk '/data/virtual_LINUX_2/LEAP_15.3_VM_TEST_CONFIG/VDI/LEAP_15.3_VM_TEST_CONFIG.vdi' {289e455f-4c8a-4eca-88b5-2756e1d2cfe3} because a hard disk '/virtual_LINUX_1/LEAP_15.3_VM_1_INITIAL/VDI/LEAP_15.3_VM_1_INITIAL.vdi' with UUID {289e455f-4c8a-4eca-88b5-2756e1d2cfe3} already exists.
Result Code:
NS_ERROR_INVALID_ARG (0x80070057)
Component:
VirtualBoxWrap
Interface:
IVirtualBox {d0a0163f-e254-4e5b-a1f2-011cf991c38d}
Callee RC:
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
This is the expected behaviour.

One have a vdi file of a defective VM.
The file is store somewhere, and the defective VM has been deleted from the virtualbox manager.
There is no longer any reference to any of the configuration files of this machine.
You create a new vm with any iso file of your preferred OS.
You add the defective VM has a secondary disk.
When adding the vdi to be repaired you can see in /home/user/VirtualBox VMs/new vm/new vm.vbox :
A new HardDisk is added here :

Code: Select all

    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{4b2fd851-faa1-405a-93c6-c7a364894f63}" location="/data/virtual_LINUX_2/CD-RESCUE_VBOX_READ_OTHER_VDI/VDI/CD-RESCUE_VBOX_READ_OTHER_VDI.vdi" format="VDI" type="Normal"/>
--->      <HardDisk uuid="{ab2e63c9-5367-4dfe-bc45-2e484f96be87}" location="/data/virtual_LINUX_2/LEAP_15.3_DEFECTIVE_VM/VDI/LEAP_15.3_DEFECTIVE_VM.vdi" format="VDI" type="Normal"/>
      </HardDisks>
and there :

Code: Select all

        </StorageController>
        <StorageController name="SATA" type="AHCI" PortCount="2" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
          <AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
            <Image uuid="{4b2fd851-faa1-405a-93c6-c7a364894f63}"/>
          </AttachedDevice>
          <AttachedDevice type="HardDisk" hotpluggable="false" port="1" device="0">
--->         <Image uuid="{ab2e63c9-5367-4dfe-bc45-2e484f96be87}"/>
          </AttachedDevice>
Now once you have finished the job, you remove the secondary disk ( vdi of the failed vm ) using the virtualbox manager.

Examining the .vbox file, the secondary disk has "{ab2e63c9-5367-4dfe-bc45-2e484f96be87}" been removed from the attached device :

Code: Select all

        </StorageController>
        <StorageController name="SATA" type="AHCI" PortCount="2" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
          <AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
            <Image uuid="{4b2fd851-faa1-405a-93c6-c7a364894f63}"/>
          </AttachedDevice>
        </StorageController>
      </StorageControllers>
But not from hardisk :

Code: Select all

    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{4b2fd851-faa1-405a-93c6-c7a364894f63}" location="/data/virtual_LINUX_2/CD-RESCUE_VBOX_READ_OTHER_VDI/VDI/CD-RESCUE_VBOX_READ_OTHER_VDI.vdi" format="VDI" type="Normal"/>
        <HardDisk uuid="{ab2e63c9-5367-4dfe-bc45-2e484f96be87}" location="/data/virtual_LINUX_2/LEAP_15.3_DEFECTIVE_VM/VDI/LEAP_15.3_DEFECTIVE_VM.vdi" format="VDI" type="Normal"/>
      </HardDisks>
Then you run into problems when adding the repaired VM. :

Code: Select all

Failed to open the disk image file /data/virtual_LINUX_2/LEAP_15.3_REPAIRED_VM/VDI/LEAP_15.3_REPAIRED_VM.vdi.

Cannot register the hard disk '/data/virtual_LINUX_2/LEAP_15.3_REPAIRED_VM/VDI/LEAP_15.3_REPAIRED_VM.vdi' {ab2e63c9-5367-4dfe-bc45-2e484f96be87} because a hard disk '/data/virtual_LINUX_2/LEAP_15.3_DEFECTIVE_VM/VDI/LEAP_15.3_DEFECTIVE_VM.vdi' with UUID {ab2e63c9-5367-4dfe-bc45-2e484f96be87} already exists.

Result Code: NS_ERROR_INVALID_ARG (0x80070057)
Component: VirtualBoxWrap
Interface: IVirtualBox {d0a0163f-e254-4e5b-a1f2-011cf991c38d}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)

So the vdi file should also be removed from harddisk paragraph.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtualbox manager does not update vm file config

Post by fth0 »

jcdole wrote:
fth0 wrote:Generally speaking, I'd prefer a different method of repairing a virtual hard disk of a VM:

I'd simply boot the original VM from a GParted Live ISO (or another Linux Live ISO) and repair the virtual hard disk just in place.
If you boot the original VM ( the one to be repaired, just in case if the vm boot ) you cannot modify the filesystem because the root partition is mounted and you cannot umount the root partition.
So you must run another VM and add the default machine as a simple additional hard drive.
You have a misconception here. If you boot the original VM from a Linux Live ISO, the root filesystem is on the virtual optical disk, not on the virtual hard disk. In the case of the GParted Live ISO, the virtual hard disk will not even be mounted at all, because then GParted couldn't modify it either, making the whole idea of a GParted Live ISO moot.

This was just a suggestion to make live much easier for you. ;) But back to your question:
jcdole wrote:So the vdi file should also be removed from harddisk paragraph.
When I (sort of) did what you did (and avoided the mentioned pitfalls), the HardDisk entry was removed from the MediaRegistry section as expected. I don't know (yet) what you're doing differently ...

As an idea: Inside the VirtualBox Manager, open the Virtual Media Manager to investigate the current state of the Media Registry. Hovering over an entry shows in a popup where the media is used ...

... and this made me realize your problem: In the Virtual Media Manager, there is a difference between Release and Remove. The former is what you implicitly did when "detaching" the virtual hard disk from a VM, but the latter is necessary to remove it from the Media Registry.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Virtualbox manager does not update vm file config

Post by scottgus1 »

fth0 wrote: there is a difference between Release and Remove. The former is what you implicitly did when "detaching" the virtual hard disk from a VM, but the latter is necessary to remove it from the Media Registry.
Yes, this. "Release" only disconnects the drive from the VM(s) it's attached to. It does not delete the drive file from the knowledge of Virtualbox.

"Remove" is what causes Virtualbox to forget about the drive file altogether. After the file is removed, you can re-register it.

If Virtualbox has released the file from its VM(s) but not removed it, then you cannot register it again with Virtualbox. The same disk cannot be registered more than once.

However, if you have only released the drive file and not removed it, then the Virtual Media Manager will still show the drive file available, and you can still attach it to the desired repair VM. You would not register the file, you'd only attach it: click the repair VM's disk controller, Add a Disk, Choose Existing, then pick a disk to be repaired from the mini-Media-Manager that appears. No registering required and no errors.

In fact, you don't need to even release the drive file from the original VM. You can attach a drive to as many VM's as you want. You can only run one VM accessing the drive at a time, but Virtualbox will not complain about the same drive file being attached to an original and a repair VM.
jcdole wrote:So the vdi file should also be removed from harddisk paragraph.
Don't look too deeply into the .vbox files. As a free Virtualbox user, you have not been invited into the great secrets of the seventh circle. Acolytes are not to know of such mysteries. :D

As fth0 pointed out above, the background VboxSVC may overwrite the .vbox files at any time, and you don't need to decode what's in the files. Just trust and use the Media Manager.
jcdole
Posts: 95
Joined: 3. May 2013, 18:25
Primary OS: openSUSE
VBox Version: PUEL
Guest OSses: WIN 7, WIN 10
Location: South west of france

Re: Virtualbox manager does not update vm file config

Post by jcdole »

Cannot find any release options in virtualbox manager :
https://paste.opensuse.org/35581535
https://paste.opensuse.org/42384444
https://paste.opensuse.org/59941512

before remove :
https://paste.opensuse.org/2983709
After removing attachement nothing change in the config (~/VirtualBox VMs/GECKO_VBOX_READ_OTHER_VDI/GECKO_VBOX_READ_OTHER_VDI.vbox
https://paste.opensuse.org/59023844
"Remove" is what causes Virtualbox to forget about the drive file altogether. After the file is removed, you can re-register it.
Seems not true.
Or remove has another meaning in virtualbox ?
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Virtualbox manager does not update vm file config

Post by fth0 »

jcdole wrote:Cannot find any release options in virtualbox manager
fth0 wrote:As an idea: Inside the VirtualBox Manager, open the Virtual Media Manager to investigate the current state of the Media Registry. Hovering over an entry shows in a popup where the media is used ...

... and this made me realize your problem: In the Virtual Media Manager, there is a difference between Release and Remove. The former is what you implicitly did when "detaching" the virtual hard disk from a VM, but the latter is necessary to remove it from the Media Registry.
FWIW, you may have missed the "Virtual Media Manager" part of my statements, which is where you'll find the Release button.
Post Reply