How to Create Clones and Snapshots of Virtual Machines in VirtualBox

Make copies of Ubuntu images quickly and easily

What to Know

  • Clone: Select and right-click virtual machine > Clone. Name the clone > Next > Full clone > Clone.
  • Snapshot: Select virtual machine > Snapshots tab > Take.
  • Restore snapshot: Select VM > Snapshots > snapshot > Restore. Uncheck Create A Snapshot Of … > Restore > snapshot.

VirtualBox 5.2.20 lets you save and restore a virtual machine you're running on your device. Instructions were created with the Ubuntu Server 18.04, but the process is the same no matter what guest operating system you're working with.

Create a Clone

As stated, clones are one of the best ways to create an exact copy of a virtual machine. One very handy way to make use of clones is to create a clean virtual machine of, say, Ubuntu Server, and then clone the original for a fresh base that can be used for any purpose.

So with a clean Ubuntu Server 18.04 virtual machine in place (and either off or in a saved state, as clones cannot be created while a virtual machine is running), you can create a clone by following these steps:

Virtual circle of prisms
  1. Open VirtualBox.

  2. Select the virtual machine to be cloned in the left pane.

    Selecting a virtualbox.
  3. Right-click the virtual machine to be cloned. Select Clone from the popup menu.

    Selecting Clone.
  4. When prompted, give the clone a name, and press Next.

    Naming clone.
  5. Select Full clone from the Clone type window, and press Clone. Depending on how large your virtual machine is, the cloning process can take anywhere from five to 20 minutes.

    Make sure to give the clone a fitting name for its usage, otherwise, you might wind up with a lot of clones with similar names (which could be confusing).

  6. When the process completes, your clone is ready to use.

Create and Use Snapshots

Snapshots are a great way to save a particular state of a virtual machine (VM). Say, for instance, you plan on installing something new on (or making a change to) a working VM and you want to make sure you have a “saved point” that you can roll back to (in case things go awry).

Let’s use the same Ubuntu Server VM to create a snapshot. Say you’re about to install a LAMP stack (or a major upgrade) and you want to make sure you can rollback, on the off-chance the install/upgrade breaks something you’ve installed and configured.

  1. To create the snapshot, select the VM to be used in the left pane, and select the Snapshots tab near the top of the window.

  2. In the resulting screen, press Take.

  3. Press OK, and the snapshot will be taken. You should now see the name of the snapshot listed with Current State below.

Restore a Snapshot

To restore a snapshot, follow these steps:

  1. Select the virtual machine to work with from the left pane in the main window.

    Selecting a virtualbox.
  2. Select Snapshots near the top of the window.

    Selecting Snapshots.
  3. Select the snapshot you want to restore.

    Selecting a snapshot.
  4. Press Restore.

    Selecting Restore.
  5. In the resulting window, uncheck the box for Create A Snapshot Of The Current Machine State.

  6. Press Restore.

  7. Select the snapshot you want to restore.

The reason why you'd uncheck the box for Create A Snapshot Of The Current Machine State is simple. If you’re rolling back to a previous state, because the current state is broken, you don’t want to take a snapshot of that broken state. When you uncheck that box, the broken state will be discarded.

It is also possible to restore a snapshot from the Close dialog.

Another Way to Restore a Snapshot

Another way of restoring a snapshot is through the Close Virtual Machine dialog.

The one caveat to this method is that it only allows you to restore to the previous snapshot (instead of being able to select a specific snapshot, as you could in the previous method).

  1. With a VM running, select File > Close.

  2. In the resulting window, check Power off the machine and then check Restore current snapshot.

  3. Press OK and the snapshot will be restored. At this point, your virtual machine will have rolled back to the state found in the restored snapshot. Any change made after that snapshot will be gone.

    More About Clones and Snapshots

    Virtual Machines have been a game-changer for testers, admins, and data centers. For those who prefer using open source technology, VirtualBox is an incredible way of creating and managing virtual machines. Two features of VirtualBox that every admin should understand how to use are clones and snapshots.

    What are clones and snapshots? Simply put, clones are an exact copy of a working virtual machine, while snapshots allow you to save a particular state of a virtual machine (which can be handy when you want to test something, or you're about to make a change to that virtual machine, and need to be able to roll back to a working instance, should something break).

Was this page helpful?