[SOLVED] Snapshots und VDIs manuell entfernen

Allgemeine Diskussionen über den Einsatz von VirtualBox.
Post Reply
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

[SOLVED] Snapshots und VDIs manuell entfernen

Post by Emma2 »

Ich habe immer noch ein Problem mit den Snapshots einer VM.
(Nein, ich nutze Snapshots nicht als Pseudo-Backups, sondern ich "merke" mir damit verschiedene Installationszustände des Systems.)

Meine VM hat verschiedene Snapshots:

Code: Select all

$ vboxmanage snapshot w11-64i list
   Name: Updates [2021-42] (UUID: 3521ae0b-d13b-4327-9dc2-19505e5cf22b)
      Name: XXXX (UUID: 7a7da4b8-7a02-4ae3-a8d6-62fad385366d)
         Name: Updates [2021-47] (UUID: 5edba047-d8b3-4f84-bf10-554788e0a6a2)
            Name: [2021-12-04] (UUID: 885c0c79-d735-4781-939d-37cda0f43563)
            Name: YYYY (UUID: e8e20277-1021-4b4e-8d19-5a65ae7cb591) *
      Name: ZZZZ (UUID: 49160d85-e4f0-495b-808f-4168de2a83df)
         Name: AAAA (UUID: ead2abf9-48a7-4f6d-9b93-4441b3807006)
      Name: Base [2227] (UUID: 5c03c817-e7f1-4d22-8114-bfc4762195e8)
Den Snapshot [2021-12-04] kann ich nicht löschen, weil dessen vdi-Datei fehlt:

Code: Select all

$ vboxmanage snapshot w11-64i delete 885c0c79-d735-4781-939d-37cda0f43563
Deleting snapshot '[2021-12-04]' (885c0c79-d735-4781-939d-37cda0f43563)
0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Snapshot operation failed
VBoxManage: error: Cannot lock hard disk '/VMs/1820/w11-64i/Snapshots/{ac696bd5-02e1-4d32-bce4-17a22b7dee5d}.vdi' when deleting a snapshot
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine
VBoxManage: error: --------
VBoxManage: error: Could not open the medium '/VMs/1820/w11-64i/Snapshots/{ac696bd5-02e1-4d32-bce4-17a22b7dee5d}.vdi'.
VBoxManage: error: VD: error VERR_FILE_NOT_FOUND opening image file '/VMs/1820/w11-64i/Snapshots/{ac696bd5-02e1-4d32-bce4-17a22b7dee5d}.vdi' (VERR_FILE_NOT_FOUND)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleSnapshot(HandlerArg*)" at line 552 of file VBoxManageSnapshot.cpp
Der Snapshot darüber lässt sich wiederherstellen, und die VM startet erfolgreich:

Code: Select all

$ vboxmanage snapshot w11-64i restore 5edba047-d8b3-4f84-bf10-554788e0a6a2
Restoring snapshot 'Updates [2021-47]' (5edba047-d8b3-4f84-bf10-554788e0a6a2)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage startvm w11-64i --type headless
Waiting for VM "w11-64i" to power on...
VM "w11-64i" has been successfully started.
Ebenso der "Bruder"-Snapshot:

Code: Select all

$ vboxmanage snapshot w11-64i restore e8e20277-1021-4b4e-8d19-5a65ae7cb591
Restoring snapshot 'YYYY' (e8e20277-1021-4b4e-8d19-5a65ae7cb591)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ vboxmanage startvm w11-64i --type headless
Waiting for VM "w11-64i" to power on...
VM "w11-64i" has been successfully started.
Die fehlende Disk steht auch als "inaccessible" in vboxmanage list hdds (Auszug):

Code: Select all

UUID:           ac696bd5-02e1-4d32-bce4-17a22b7dee5d
Parent UUID:    a3c28992-5300-4231-b42e-30095797b3fc
State:          inaccessible
Type:           normal (differencing)
Location:       /VMs/1820/w11-64i/Snapshots/{ac696bd5-02e1-4d32-bce4-17a22b7dee5d}.vdi
Storage format: VDI
Capacity:       0 MBytes
Encryption:     disabled
Kann ich diesen Snapshot und die VDI manuell "loswerden"? Wie müsste ich vorgehen?
Da er das Ende einer Kette ist, brauche ich ihn nicht, es entsteht also kein Datenverlust.
Last edited by Emma2 on 9. Jul 2022, 12:53, edited 1 time in total.
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: Snapshots und VDIs manuell entfernen

Post by fth0 »

Emma2 wrote:Kann ich diesen Snapshot und die VDI manuell "loswerden"? Wie müsste ich vorgehen?
Ja. Den Host neu starten oder anderweitig sicherstellen, dass keine VirtualBox-Komponente läuft. Dann die Konfigurationsdatei w11-64i.vbox in einem Texteditor öffnen und im Abschnitt MediaRegistry die entsprechende HardDisk-Zeile löschen.
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

Und den Snapshot? Kann ich den dann "gefahrlos" aus der vbox-Datei löschen? Oder wo steht der?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Snapshots und VDIs manuell entfernen

Post by mpack »

Editing of .vbox files is not something we ordinarily recommend for new users. However, if you zip the .vbox file and attach the zip here, then a more experienced user can make the edits for you. Once done you can delete the files in the Snapshots subfolder.

And it would be useful to make a backup of the VM folder before you start.
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

Thanks a lot for your help and advice.
I rsync'd my VM directory now, unregistered the VM, deleted the "dead" snapshot's XML node, deleted the orphaned disk's XML node, saved the file and registered the VM anew.
Seems to work fine.

There's one riddle left, however: In the <MediaRegistry> node, there are now eight entries (including the base vdi), all of them correspond to a VDI file,
but in the Snapshots directory, there is one more vdi file. Is it "safe" to delete that one now? (I am sure that this disk isn't used in any other VM.)
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

Emma2 wrote: There's one riddle left, however: In the <MediaRegistry> node, there are now eight entries (including the base vdi), all of them correspond to a VDI file,
but in the Snapshots directory, there is one more vdi file. Is it "safe" to delete that one now? (I am sure that this disk isn't used in any other VM.)
Now, this definitely causes a problem:
I unregistered the VM, renamed (not deleted) the orphaned vdi file, but after this, registering of the VM fails with a message of

Code: Select all

$ vboxmanage registervm /VMs/1820/w11-64i/w11-64i.vbox
VBoxManage: error: A differencing image of snapshot {49160d85-e4f0-495b-808f-4168de2a83df} could not be found. Could not find an open hard disk with UUID {f5e05c09-5f8b-4319-8371-13df1a308e01}
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SnapshotMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "OpenMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 85 of file VBoxManageMisc.cpp
Which puzzles me most (probably due to my lack of details knowledge)i is the fact, that even after re-renaming the vdi file, I still cannot register the VM again.
How comes this?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Snapshots und VDIs manuell entfernen

Post by mpack »

Emma2 wrote: Which puzzles me most (probably due to my lack of details knowledge)i is the fact, that even after re-renaming the vdi file, I still cannot register the VM again.
How comes this?
I'm not sure if I'm following what you mean, but several objects in VirtualBox have UUIDs, not just disks. Attempting to re-register a VM will cause VM-UUID conflict. I'm also not sure why re-registering is necessary, but I have not followed this discussion very closely.
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: Snapshots und VDIs manuell entfernen

Post by fth0 »

Emma2 wrote:Und den Snapshot? Kann ich den dann "gefahrlos" aus der vbox-Datei löschen? Oder wo steht der?
Ups, den hatte ich heute Mittag auf die Schnelle total vergessen. Ja, der steht auch in der vbox-Datei, besteht aber aus einem mehr oder wenigen großen Abschnitt. Am Einfachsten müsste es sein, aus dem richtigen Snapshot-Abschnitt nur den Image-Abschnitt mit der UUID der virtuellen Disk zu löschen und damit praktisch die virtuelle Disk zu entfernen, und danach den Snapshot normal über den VirtualBox Manager zu entfernen.
Emma2 wrote:Which puzzles me most (probably due to my lack of details knowledge)i is the fact, that even after re-renaming the vdi file, I still cannot register the VM again.
How comes this?
The VDI file contains several UUIDs in the VDI header. Changing only the filename is not sufficient to fool VirtualBox. ;)
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

Hi, mpack and fth0...

Ill try to jot it down in an understandable way... :?

1. The problem is "sufficiently solved" more me - in that I can use my VM now, and I got rid of the unwanted/unneeded snapshots.
1a. To achieve this, I unregistered the VM - to be able to edit the vbox file without having it "repaired" with the cached version
1b. After this, I edit the vbox file, looked for the <Snapshot> XML node for the snapshot in question, noted its storage's UUID, and deleted the node
1c. Deleted the hdd's XML node in the <MediaRegistry> node
1d. Registered the VM anew to be able to use it.

2. After that, I was eager to get rid of the unused vdi files, and I noticed that there was one which wasn't mentioned in the VM's vbox file.
2a. I renamed that file (in case I would need it though) - and I am "quite" sure that it wasn't mentioned any longer in the vbox file
2b. To check whether everything were ok, I unregistered the VM and tried to re-register it...
2c. ... which FAILED - due to that file missing!
2d. I restored the file's former name - but I still could not register the VM again - because the system "Could not find an open hard disk with UUID {f5e05c09-5f8b-4319-8371-13df1a308e01}"
2e. For me, this says that, if a vdi file is not found (having been renamed), it will be "deleted" from the vbox file - so that restoring it does not help to have it "in the vbox file" again. Can this be the case?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Snapshots und VDIs manuell entfernen

Post by mpack »

Emma2 wrote: 2e. For me, this says that, if a vdi file is not found (having been renamed), it will be "deleted" from the vbox file - so that restoring it does not help to have it "in the vbox file" again. Can this be the case?
No, as far as I'm aware that is not the case. Actually I know for a fact if you rename a VDI then the old name will remain registered, and the various locations in VirtualBox such as the Virtual Media Manager will continue to show the VDI as registered, but currently inaccessible. This will be resolved when the old filename is restored to its original name and folder.
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

mpack wrote: Actually I know for a fact if you rename a VDI then the old name will remain registered, and the various locations in VirtualBox such as the Virtual Media Manager will continue to show the VDI as registered, but currently inaccessible. This will be resolved when the old filename is restored to its original name and folder.
And exactly THIS did NOT work for me, as I described. I will try this once again and report later.
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: Snapshots und VDIs manuell entfernen

Post by fth0 »

Perhaps the following can help understanding some relations:

1. VirtualBox.xml contains the MachineRegistry, which represents the registered VMs and links to their .vbox files, and the MediaRegistry is the sum of all MediaRegistry sections of those .vbox files. Depending on what VirtualBox features you're using (e.g. Linked Clones, Multiattach Mode Images), some HardDisk entries could be located in one .vbox file and be used in another .vbox file. The HardDisk entries link to the filenames of the virtual disk images.

2. The virtual disk images contain a header (e.g. VDI header) with their own UUID and their parent UUID. You've seen this information in the output of VBoxManage list hdds.

In consequence, there are several UUID trees that must be held consistent (MediaRegistry, Snapshot trees, VDI headers). That's why users are normally not encouraged to edit the configuration files by hand.

You could search for the missing UUID in all the places I mentioned above. Another possibility is that the information is only cached inside the VBoxSVC process, were it will stay as long as any VirtualBox component is running.
Emma2
Posts: 51
Joined: 16. Feb 2021, 11:59

Re: Snapshots und VDIs manuell entfernen

Post by Emma2 »

Thanks for that explanation. Maybe, I'll search for the UUIDs "as soon as I'll have the time" ;-)
But for now, I can ignore the problem - simply because the vdi files in question are merely 2 MB in size...
Post Reply