Branching snapshots / virtual disks in VirtualBox

I recently became a big fan of VirtualBox. It’s a great virtual machine / x86 emulator, has great performance and with guest additions integrates nicely in the host system.

The only feature that I missed (and others too) was branching of snapshots/virtual disks. A typical use case would be to install an OS into a virtual disk, make that virtual disk read-only and use it as base image for several branches. For example, in one branch I would do testing/debugging of stuff that I develop. There might be several branches I use for testing. Then I might need a branch in which I install a build environment for OpenJDK, which could in turn be used for several more sub-branches for OpenJDK6 builds and OpenJDK7 builds. In another branch off the base image I would run tax software. Etc etc. You get the idea.

Today I realized that this is actually already possible, it’s just not obvious how to do it. Steps to create branches from a base image:

  1. Setup base VM with base VDI.
  2. Install OS into this VM.
  3. Take snapshot of this base installation.
  4. Now you have your original .vdi file readonly and another .vdi file with a cryptic name as the new working difference for that VM.
  5. Create a new VM and attach the original VDI to it. This will create a NEW .vdi, again with a cryptic name, based on the readonly snapshot.
  6. You can repeat that process, even for sub-trees.

In the screenshot below you see a Windows XP base image with tree sub-trees. The first subtree has another 2 subtrees. Note that in each VM you only see one path in snapshots. And of course you can not delete/merge snapshots with more than 1 children.


3 Responses to Branching snapshots / virtual disks in VirtualBox

  1. Pingback: This note’s for you » Blog Archive » What am I doing at Sun?

  2. Jon says:

    Nice one !!

    Pity that there’s a need to create another VM… I don’t think that there’s all that much missing in the UI for this to be implemented. In that case no worries about not getting the conf just right, MAC addresses changing & so on…

    Before coming accross your Post I was fiddling around with VBoxManage and came accross the adoptstate command – no real documentation on how this works… Any ideas ?

  3. BertBert says:

    “And of course you can not delete/merge snapshots with more than 1 children.”

    I removed all children in the original branch, but I couldn’t figure out how to merge the snapshot in the new branch with the original disk.. Any ideas?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: