(For more resources related to this topic, see here.)
Much ado about snapshots (Intermediate)
Snapshots are a fantastic feature of VMware Fusion because they allow you to roll the VM back in time to a previously saved state. Using snapshots is easy, but understanding how they work is important.
Now, first things first. A snapshot is not a backup, but rather a way to either safely roll back in time or to keep multiple configurations of an OS but share the same basic configuration. The latter is very handy when building websites. For example, you can have one snapshot with IE7, another with IE8, another with IE9, another with IE10, and so on.
A backup is a separate copy of the entire VM and/or its contents (“Your VM” and “Your Data”) on a different disk or backup service. A snapshot is about rolling back in time on the same machine.
If you took the snapshot when we finished installing Windows 7 but before upgrading to Windows 8, you can easily switch back and forth between Windows 7 and 8 by simply restoring the state. Let’s see how.
Firstly, the VM doesn’t have to be running, but it can be. The snapshot feature is powerful enough to work even when the VM is still running, but goes much faster if the virtual machine is powered off or suspended. We can use the snapshot we took when we finished installing Windows 7. If you didn’t take a snapshot at that time, you can go ahead and take a new snapshot now by clicking on the Take button from the snapshot window.
How to do it…
Snapshots are best taken when a VM is powered off. It doesn’t have to be, but your computer will complete the “Take Snapshot” operation much faster if the VM is powered off or suspended. Both fully powered off and suspended tasks are much faster because the VM isn’t in motion when the snapshot is taken, allowing the operation to finish at a single stroke. Otherwise, the way the snapshot mechanism works when a VM is running is that once it finishes, it has to now gather the new data that changed from when the snapshot operation started. So, if it took five minutes to take a snapshot, it then has to gather itself up to date for those five minutes. That might take a minute. After that, it has to go back again to gather that last minute. If that minute takes 20 seconds, it has to then gather those 20 seconds again. This is made worse with the more things you’re doing within the virtual machine. So, get it done in one motion by suspending or powering off the VM first.
Launching the snapshot window and examining the tree
The following sequence of steps is used to initiate the snapshot process:
Click on the Snapshots button in the VM window and have a look at the snapshot interface. In my example, the following was the view of my “tree” right after we finished installing Windows 7:
When I finished upgrading to Windows 8, I took another snapshot. This allows me to go back in time to both a fresh Windows 7 and Windows 8 installation, as shown in the following screenshot:
Restoring a snapshot
Having a TARDIS or DeLorean might be more fun, but for the rest of us, we can go back in time by restoring a snapshot. Let’s go back to Windows 7 from our Windows 8 VM.
Follow these steps:
In the Snapshot Manager window, simply double-click on the base disk at the top of the tree to restore it. It will ask about saving the current state. Choose Save when prompted asks as shown in the following screenshot. You can rename the snapshot at any time from this window by right-clicking on the name and clicking on Get Info.
After a few seconds, depending on the speed of your Mac, the older version should now show as the Current State, as shown in the following screenshot. If the VM was running, it should just show up now as being Windows 7. If you see a spinning wheel in the upper-right corner, that’s the “disk cleanup” activity working in the background. You can use the VM while it’s doing this; however, it might be a bit slow on disk access while it’s cleaning up the disks. If the VM is suspended or powered off when restoring, the operation is much faster because the VM isn’t changing/running.
With this technique, you can switch between Windows 7 and Windows 8 with ease.
How it works…
In Fusion, all of the VM’s files, are stored under Documents | Virtual Machines by default. Your C: drive in Windows is actually a series of files on the Mac named in sequence, with a .vmdk extension inside the Virtual Machines folder, as shown in the following screenshot. You can view the files by right-clicking on the VM and clicking on Show Package Contents from the Virtual Machines folder in the Finder.
When you create a VM, it starts with one virtual disk (called the base disk). This virtual disk, or VMDK, is broken up into 2 GB “chunks” by default, but it can be one big chunk if desired. So, for a 20 GB disk, you end up with about 10 or 11 .vmdk files. This is for easy transport with drives that don’t support large drives (such as MS-DOS/FAT32-formatted drives), and you may also have a performance benefit in certain cases.
When you take a snapshot, the currently active VMDK goes into read-only mode, and a new VMDK is created. All writes go to the new VMDK, and reads happen from the original VMDK when the bits are there. Fusion is smart enough to keep track of what files are where; so, when the VM is running, Fusion is reading all of the snapshots in the current state’s chain.
A .vmdk file is thus named <disk_name>-<snapshot_number>-<slice>.vmdk.
So, in my example, Virtual Disk is my disk name. (I could have customized and specified something different by performing a Custom Virtual Machine operation at the beginning.)
I have three disks: Virtual Disk, Virtual Disk-000001, and Virtual Disk-000003. This means I have two snapshots and a base disk. (I took one snapshot and deleted it, which is why there’s no Virtual Disk-000002).
Each of those disks are of 60 GB capacity, so there are 31 slices. (s001 to s031). Each file starts around 300 KB and can grow to just over 2 GB. You can see where things can start to get confusing now.
It gets even better when you have snapshots that are based on snapshots. You can have multiple snapshots with a common parent, which introduces a new concept in Fusion, that is, snapshot trees.
Snapshots are also a great way to make sure something new isn’t going to destroy your VM. So, if you are about to install some software that might be risky, take a snapshot. It’s easy to roll back if something goes wrong.
Snapshots are complicated, but there’s great material out there by the gurus behind Fusion itself about how they work on a more technical level.
You can read more about snapshots from Eric Tung, one of the original developers of Fusion (the blog is a bit old, but still completely accurate with respect to how snapshots work) at http://blogs.vmware.com/teamfusion/2008/11/vmware-fusion-3.html.
A great article by Eric to dispel some of the confusion around snapshots and how to use them is available at http://blogs.vmware.com/teamfusion/2008/11/bonustip-snaps.html.
One thing to note is that the more snapshots you have, the more effort the Mac has to make to “glue” them all together when you’re running your virtual machine. As a rule of thumb, don’t take snapshots and keep them around forever if you don’t intend on rolling back to them regularly.
Also, each snapshot can grow to be the size of the entire C: drive in Windows. Use them when necessary, but be aware of their performance and disk-usage costs.
In this article, we studied about snapshots and their usage. It shows you how to use this to make one virtual machine with both Windows 7 and Windows 8.
Resources for Article:
- An Introduction to VMware Horizon Mirage [Article]
- Windows 8 with VMware View [Article]
- Securing vCloud Using the vCloud Networking and Security App Firewall [Article]