How to Use Branched Snapshots in VirtualBox
VirtualBox has supported virtual machine (VM) snapshots for a while. However, until version 3.1, it was only possible to revert back to a previous state which destroyed snapshots lower in the hierarchy.
VirtualBox 3.1 introduces a great new feature that could help web developers manage multiple virtual machines (VMs). Branched snapshots allow you to create any number of VMs from a single root image. For example, you could install a clean copy of Windows XP SP3 and, from that single image, create snapshots with multiple browser configurations.
There are a number of ways to create snapshots, but it’s easiest from the main Snapshots tab. In the following example, we’ll create three snapshots for the root, IE6 and IE7.
1. Create your VM and first snapshot
First, you’ll need to create a new VM, install an OS and all the latest patches. If you’re installing XP, I’d recommend creating a minimal installation using nLite. Once complete, shut down the VM, return to the main VirtualBox window, and click the Snapshots tab:
Highlight the Current State, then click the Take Snapshot icon (circled in red) and give it a name and description, e.g. “XP SP3”.
2. Create an IE6 snapshot
The current state should already have IE6 installed, but it’s a good idea to take another snapshot since updates will be applied over time. With the Current State highlighted, click the Take Snapshot icon and give it a name and description, e.g. “XP IE6”.
3. Revert to the root snapshot
Here’s the clever bit. Highlight the root “XP SP3” VM and click the Restore Snapshot icon (circled in red). You’ll be warned that you’ll lose the current machine state, but click Restore anyway — you won’t lose the IE6 snapshot.
4. Install IE7
Now boot the VM in it’s current state, then install IE7 and any other software you need. Once complete, shut down the VM.
5. Create an IE7 snapshot
From the Snapshot tab, highlight the Current State, click the Take Snapshot icon and give it a name and description, e.g. “XP IE7”.
That’s all there is to it. You can create as many snapshots as you need from the root VM and the disk image will only expand as differences are made. To revert to a different state, highlight the snapshot and click the “Restore Snapshot” icon before booting.
The main disadvantage with branched snapshots is they are not clones — you can only have one running at a time. It’s not possible to boot both the IE6 and IE7 image. But it’s still a great addition to VirtualBox and will help you test browsers and other software.