Branching snapshots / virtual disks in VirtualBox
July 8, 2009 3 Comments
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:
- Setup base VM with base VDI.
- Install OS into this VM.
- Take snapshot of this base installation.
- Now you have your original .vdi file readonly and another .vdi file with a cryptic name as the new working difference for that VM.
- 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.
- 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.