merge differential vdi

This is for discussing general topics about how to use VirtualBox.
Post Reply
reids
Posts: 5
Joined: 2. Jan 2017, 15:41

merge differential vdi

Post by reids »

How do I merge a VDI that has children with its parent?
Cannot close medium 'xyz.vdi' because it has 1 child media.
My structure looks like this:

Code: Select all

base.vdi
-snap1.vdi
--snap2.vdi
---snap3.vdi
I want to achieve this:

Code: Select all

base.vdi
-snap1.vdi
--snap3.vdi
Sorry if there is already an answer - just post the link, please. I can't believe that such a simple thing is not already solved, but I wasn't able to find a solution except deleting the children (and losing their data) or merging everything with clonehd (and losing all other snapshots). Thanks!
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: merge differential vdi

Post by mpack »

Snapshots are conceptually just timeline markers, giving you the ability to revert to past moments in the history of the VM. So if you no longer need the latter ability then simply delete the marker. You shouldn't need to concern yourself with exactly how that is done (e.g. whether it involves merging anything or not).

Deleting an old marker doesn't change the data available to the current state, it only removes your ability to revert to a specific earlier state. So, if you delete the oldest snapshot then the VM will keep working as before, with the same data, but it will take up less disk space on the host. You can call this a merge if you like. You can keep deleting the oldest snapshot until you are left with just the current state. Don't ever try to delete the current state! I don't actually use snapshots, so I'm not entirely sure what deleting the current state would do, I only know that it doesn't make much sense to try.
reids
Posts: 5
Joined: 2. Jan 2017, 15:41

Re: merge differential vdi

Post by reids »

Thanks for the reply. You're right, in this specific situation with a straight timeline and a single vm it is really working when I use the Snapshot Manager (not the Virtual Media Manager) to delete a snapshot. But what if the differencing disk is not connected with any snapshot, e.g. after some cloning, deleting etc.? VMM says "not attached", but the differential disk image is still there and consuming space.

Moreover, the timeline is not always straight. You can have any kind of tree. Another example:

Code: Select all

base
-snap1
--snap2
---snap3
---snap4
After deleting snap2, it should look like this:

Code: Select all

base
-snap1
--snap3
--snap4
Hard disk 'Snapshots/{abc}.vdi' has more than one child hard disk (2).
What is the problem?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: merge differential vdi

Post by mpack »

Cloning and deleting what? If you clone VDIs at the basement level (in a VM which uses snapshots) and then mount the clones in the original VM then that would rather thoroughly screw up the VM.

Also, not all difference images are snapshots, though they usually are - which is why I assumed that's what you were talking about (sans any info to the contrary). Linked clones (whether you are the cloned or the clonee), immutable drives, and use of compressed VMDK without unpacking it also involve the use of differenced images. Which of these is the VM actually using?

Cutting to the chase: a full clone of the VM, current state only, will create a clone VM which has no difference image attachments. The original VM can then be deleted. Cloning the VM will change disk and "motherboard" UUIDs, which may be visible to grub boot and IPR signature tools such as Windows activation.
reids
Posts: 5
Joined: 2. Jan 2017, 15:41

Re: merge differential vdi

Post by reids »

My setup is using linked clones and a complex snapshot tree on each vm. The situation with orphaned differencing images arose after full cloning (including snapshots) a linked clone.

How do I delete these? I cannot do a full clone (current state only) as you suggested because I need the other snapshots.
socratis
Site Moderator
Posts: 27330
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: merge differential vdi

Post by socratis »

reids wrote:

Code: Select all

base.vdi
-snap1.vdi
--snap2.vdi
---snap3.vdi
I want to achieve this:

Code: Select all

base.vdi
-snap1.vdi
--snap3.vdi
Delete --snap2.vdi
reids wrote:

Code: Select all

base
-snap1
--snap2
---snap3
---snap4
After deleting snap2, it should look like this:
You cannot delete snap2, because it has two children, snap3 and snap4. VirtualBox would have to do two merges. Snapshots are fragile as they are, you don't need to add any more complexity. So that would be a big "no".
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.
socratis
Site Moderator
Posts: 27330
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: merge differential vdi

Post by socratis »

reids wrote:I cannot do a full clone (current state only) as you suggested because I need the other snapshots.
Post either a screenshot of the tree, or the <VM_Name>.vbox. Right-click on the VirtualBox Manager on the VM, show in Finder/Explorer/Whatever... Please do not obfuscate the data (UUIDs).
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.
reids
Posts: 5
Joined: 2. Jan 2017, 15:41

Re: merge differential vdi

Post by reids »

Situation 1: Everything above the selected vdi is not attached. It comes from the parent vm of a linked clone and was not merged when full cloning the linked clone.
snap1.png
snap1.png (31.69 KiB) Viewed 5784 times

Situation 2: The selected vdi is the same as its parent. It was generated automatically while creating a linked clone. I don't want this duplicate snapshot in my tree.
snap2.png
snap2.png (30.16 KiB) Viewed 5784 times
reids
Posts: 5
Joined: 2. Jan 2017, 15:41

Re: merge differential vdi

Post by reids »

socratis wrote:You cannot delete snap2, because it has two children, snap3 and snap4. VirtualBox would have to do two merges.
Ah, I see how it works. VirtualBox always merges into the child, not the parent. So I could delete snap1 and then rename snap2 as snap1. However, being able to merge at basement level without thinking about snapshots and so on would add a lot of flexibility. The danger is of course to damage something if you don't know what you're doing - merging into a parent would destroy its other children. With VHD files this is possible anyway.

The questions above still remain: How do I do the merge with a VDI that is not attached (situation 1)? How do I take the empty automatic snapshots out of the chain (situation 2)?
Post Reply