Thursday, November 18, 2010

Who needs Deep Freeze?

If you are an admin for large computing environments, say a college campus, you are likely familiar with a brilliant piece of software called Deep Freeze. This program allows you to "freeze" the state of a computer. From that moment on, any changes that occur on the machine will be forgotten when the computer reboots. It is some pretty sweet software, and a must have for environments that are prone to users who might mess things up.

The only problem with Deep Freeze is that it is expensive! I have recently discovered a way to use virtual hard disks (see my last post) to mimic the behavior of deep freeze. The trick is to use a parent/child relationship between vhd files. The parent vhd contains your base image. This is equivalent to the "frozen" computer with Deep Freeze. Now, make a child disk and boot to that. Anytime you want to revert to the parent vhd simply create a new child vhd based on the parent, and retarget your computer to point to the new child. Now reboot and you are back to normal. This has enormous potential to be scripted. I am currently working on a script that does this exact thing. I just couldn't wait to blog about it because this idea for maintaining a pristine lab image is just too cool.

how to create the child vhd file

diskpart
create vdisk file=c:\child.vhd parent=c:\parent.vhd
select vdisk file=c:\child.vhd
attach vdisk
select partition 1
assign letter=q
exit
rem Only do this line if you want to boot straight to the vhd without a boot menu
bcdedit /delete {default}
bcdboot q:\windows

now restart and you are done! To revert to the snapshot go through the same steps, but create a new child disk that is named something else. I have a script that generates a guid and uses that as the naming scheme for the current child disk. It seems like it will work for me, but I'm still working out the kinks.

This script assumes that windows has already been installed to c:\parent.vhd

Wednesday, November 17, 2010

Deploying an image to lots of computers

Over the last several years a very common question keeps surfacing. What is the best way to deploy an image to a large number of computers? I have changed my mind about the answer to this question many times. I have done everything from a completely scripted OS install and automated package installation, to deploying flat file images from Altriris. Well, I have come across what I believe will be a superior solution to both of those scenarios.

Boot to VHD for Windows 7 gives you the consistency of imaging with a flat file, while vastly improving the time it takes to deploy an image. The best part is that all you have to do is copy the vhd to the hard drive and run a few command line scripts. You don’t have to wait the additional step of actually writing the image to the hard drive. (However, if you do want that I’ve been very impressed with imagex for this sort of thing).

here is a  quick how to for booting to VHD.

So, it seems pretty easy to set up a single computer to boot to a VHD once you have the VHD already created. However, we seem to be skipping several steps here, like how to create the VHD in the first place, and how to deploy the thing effectively to multiple computers without absolutely killing your network.

Creating the VHD itself is not that difficult. Virtual PC already boots to vhd, and will create the file for you if needed. Simply install Virtual PC, set up a new virtual computer and install Windows 7. Then, go find the vhd file that was created, you are done! Well… sort of. If you want to be able to deploy this vhd to multiple computers you are going to want to generalize the image using sysprep.

c:\windows\system32\sysprep\sysprep /generalize /oobe /shutdown

This command line will prepare the vhd for deployment to any computer you want. Once the virtual pc has shut down you now have the vhd file that all those other tutorials are referring to.

So, now we have a handle on how to set up an individual computer to boot to a vhd. But, a key part of this process is getting the vhd to the computer in the first place. This part might take some creativity. One of the options I’ve been exploring is the use of utorrent for its actual intended, and legal, purpose (as opposed to all those pirates out there). Set up a server as a tracker for bittorrent, then host the vhd file. Have all of your computers run utorrent and download the vhd file. Once all of your computers have the vhd file you simply need to execute the script that will make the computer boot to that vhd file.

That whole scenario is still a theory. I’m currently working on implementing it. I will post later with updated details of how it works (or heaven forbid it doesn’t work). But, I have a lot of confidence that the concept is solid, even if the implementation hasn’t been nailed down.

Well, there are lots more ways to manage the deployment of images to large numbers of computers. But, this method seems to be my favorite at the moment.