How to Use Branched Snapshots in VirtualBox

Tweet

VirtualBoxVirtualBox 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:

VirtualBox 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″.

VirtualBox Snapshot 1

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″.

VirtualBox Snapshot 2

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.

VirtualBox Snapshot 3

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″.

VirtualBox Snapshot 4

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.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • Peter Mescalchin

    Brilliant Craig! Thanks for explaining that, I haven’t really played with the snapshots tab as it seemed a bit strange in it’s interface, but once explained it’s very cool.

    This will come in handy when I am working with Ubuntu server virtual machines as well. installing packages/etc. then reverting. In the past I have been cloning disc images using the “vboxmanage clonevdi” command line tool – which works great too, but is a little less elegant than this method.

  • http://www.optimalworks.net/ Craig Buckler

    Thanks Peter.

    It took me a little while to figure out branched snapshots at first. It’s quite straight-forward, but the interface and warnings can throw you.

    Cloning is more versatile if you need to boot two or more VMs at the same time. However, it takes more disk space and effort to set up.

  • http://rollerscapes.net s.stok

    Oh god yes! finally :D

  • Eric_HE

    good post!i have tried yet!

  • http://www.popbuying.com/ popbuying

    good postion,tks very much !

  • VPS

    That is fantastic!
    I’ve been a user of Virtualbox for about a year now and have been looking for a feature like this.
    Thanks for sharing!

    http://vpslime.com