Page 1 of 1

Can I merge or collapse a HD VDI?

Posted: 16. Oct 2009, 20:27
by jtalarico
I'm a VB newb, so be patient...

I have a guest OS that has a primary volume and a secondary volume. At some point I was playing around with snapshots and attaching other Guests to the external volume. All along, a whole bunch of differencing volumes were created. I discarded my snapshots and I am now left with the following:

Win7.vdi
Win2003.vdi
External.vdi
> {differencing volume}.vdi

I've got both the Win7 and Win2003 guests using the differencing volume so they can effectively share a drive and data. But I'd like to "merge" the differencing volume with the main External.vdi. Here are my questions?

1) Can you merge a differencing volume with the original? I've done this on the primary drives by discarding snapshots, but can't seem to find a way to do it on other volumes.

2) Can you attach a volume to more than one guest WITHOUT spawning a differencing volume? I've found that I can attach more than one guest to a single differencing volume, but not the original.

TIA

Re: Can I merge or collapse a HD VDI?

Posted: 17. Oct 2009, 04:41
by MarkCranness
I've only just been investigating this within the last hour or so myself, so: BACKUP before trying my suggestions.

Make sure that the differencing volume does belong to the External.vdi first (if you have not already done so): Open Virtual Media Manager and make sure that the differencing volume is a child of External.vdi.

1) You can merge the differencing hard disk with the original. In your case, the UI won't let you likely because you added the External.vdi file to one of the guests while the other guest had a snapshot on that hard disk.

To merge, first detach it from all guests (Settings>Hard Disks>Attachments>"-" icon)

Use this command to create a flattened clone of External.vdi, including the differencing volume:

Code: Select all

VBoxManage clonehd differencing-volume External2.vdi
(Replace "differencing-volume" with the UUID, excluding {} characters of the differencing volume, the command will look something like:

Code: Select all

"C:\Program Files\Sun\VirtualBox\VBoxManage" clonehd 477785b3-62f6-4b1d-961c-212b8c1fc0b6 External2.vdi
Now attach External2.vdi to the guests.
(Perhaps unregister and delete the original using Virtual Media Manager then rename the ~2 version before adding it using VMM.)

2) I think if you attach the same volume BEFORE you create snapshots on any VM, you will not have a differencing hard disk.

Note: If both guests have the same base VDI attached, VirtualBox will not let you start both VMs at the same time (which is good!)

Edit: While two or more machines share a base hard disk, you CANNOT do a snapshot on either VM!
To get around this, you will have to (carefully) detach, re-attach everytime you want to use the other VM, or decide not to use snapshots on those VMs.

Edit2: Perryg suggests to me (indirectly: in a different thread, about a different topic) to create External.vdi as a Writethrough disk, then I expect you can use Snapshots on the VMs, but the snapshots will not apply to External.vdi
See the Section 5.3 of the user manual.

Re: Can I merge or collapse a HD VDI?

Posted: 19. Oct 2009, 20:12
by jtalarico
I just got around to trying this and it worked like a charm. My host OS is Mac OS X, BTW.

The only thing I had to do is manually tweak the VirtualBox.xml configuration to remove the old virtual volume. The GUI wouldn't let me remove it even though it was attached to no VMs. I then added the newly cloned volume and attached successfully to several VMs.

Thanks!