Yes, you can create physical snapshots in the latest Windows OS!
One of my favorite virtual machine (VM) features is snapshots. Want to test something messy on your VM but don’t want to risk the necessity to rebuild the system from scratch afterward? No problem! Just take a snapshot. When you’re done with the experiment, the cleanup is just as easy as clicking Undo, and you’re quickly back where you started.
As many readers know, snapshots are more than just a convenience. Many educational institutions support uncountable numbers of physical (not virtual) student machines, all of which need to be restored to their just-like-new pristine state after every class. Now, Microsoft used to offer a free tool called SteadyState that did just that thing for Windows Vista and Windows XP, but it failed to do so for Windows 7. So, as I promised last month, this month I want to show you how to create your own home-made SteadyState functionality for Windows 7 Enterprise and Ultimate editions. Expect this solution to be a bit rough-edged at first, but I'll examine some streamlining ideas in future columns.
You can implement physical snapshot/recovery capabilities for a physical Window 7 system by combining two technologies that I’ve covered in past columns: Windows 7 Enterprise/Ultimate’s boot-from-VHD capability (“Booting Windows 7 Enterprise or Ultimate from a VHD File,” InstantDoc ID 129377), and those OSs' ability to natively support a kind of VHD called a “differencing disk” ("Diskpart Takes Snapshots of Physical and Virtual Systems,” InstantDoc ID 125233).
First, get your desktop on a VHD. You can use the procedure explained in “Creating a Bootable VHD” (InstantDoc ID 129194) or “Creating Bootable VHDs with Disk2VHD” (InstantDoc ID 125422) to set up a Windows 7 system as a bootable VHD. Call that file baseimage.vhd. (Be very sure to make baseimage.vhd an expandable VHD—not a fixed-size one—or you won’t be able to create a snapshot.) Next, you’ll want to install baseimage.vhd as a second boot option on your computer, as you read in “Creating a Bootable VHD," so copy that file to your computer and put it in a folder named C:\VHDs.
Second, using the Bcdedit commands you saw in “Booting Windows 7 Enterprise or Ultimate from a VHD File,” configure your system to boot from baseimage.vhd. At that point, use the new option to boot from baseimage.vhd and do whatever you need to get your system just the way you’d like it, prior to snapshotting it.
Now, it's time to create the snapshot. You want to be able to boot from baseimage.vhd while at the same time being able to undo any changes to baseimage.vhd, so you'll tell Windows 7 to leave baseimage.vhd unchanged and instead write any changes to a different VHD by creating a new VHD that is neither fixed nor expandable, but is instead a differencing VHD associated with baseimage.vhd. Windows refers to the original VHD as the parent VHD and the new differencing VHD as the child VHD. Windows won't let you create a child VHD to an in-use parent VHD, however, so before you can create a child for baseimage.vhd, you need to reboot to the original Windows image on the computer's C drive to free up baseimage.vhd.
Now, open Diskpart and type
create vdisk file=c:\vhds\snapshot1.vhd parent=c:\vhds\baseimage.vhd
Then, type exit to get out of Diskpart.
Just one more step, and you're in business. Using the Bcdedit commands that you used to enable your system to boot from baseimage.vhd (again, your system’s second boot option), create a third boot option, booting this time from C:\vhds\snapshot1.vhd.
Boot from that third option, and from this point on baseimage.vhd remains unchanged, and all changes go into snapshot1.vhd. You can then modify your system however you like and, when you want to return things to their pre-snapshotted state, just reboot into the first of your three boot options, open an elevated command prompt, and type
del c:\vhds\snapshot1.vhd diskpart create vdisk file=c:\vhds\snapshot1.vhd parent=c:\vhds\baseimage.vhd exit
After a reboot—again, into the third option—your system is back to its base state. As before, any new changes will go into snapshot1.vhd, and if you ever want to return to the “pristine state,” just recreate the above commands to continue to use the third boot option.
If you want to update baseimage.vhd in some way, you have two choices. Either boot to the second option and do your maintenance (the second option writes all changes to baseimage.vhd) or, if you like the changes that you’ve wrought to snapshot1.vhd and want to keep them, boot from the first option and merge snapshot1.vhd into baseimage.vhd like so:
diskpart select vdisk file=c:\vhds\snapshot1.vhd merge vdisk depth=1 exit del c:\vhds\snapshot1.vhd
Yes, I know, it's a bit kludgy. But try it out. I think you’ll see that it’s a viable replacement for SteadyState. As to the kludgy part? Well, I’ve got a few ideas to smooth that out, and I'll start examining them next month.