Start Testing with a Clean Slate
Some projects require a clean slate for proper testing. Installers are notoriously difficult to test and debug because an error in the installer may leave behind artifacts that render future tests invalid. The only proper way to test an installer is to start with a clean slate each time. However, wiping out and reinstalling an operating system can be very time consuming, especially in a heterogeneous test environment. The solution: a virtual machine with a replicated hard drive.
Most VM software products use virtual hard drives. A virtual drive is simply a single file on the host operating system that emulates a hard drive of a given size to the guest operating system. Some products even allow you to use "growing" virtual drives, which let you specify a very large size for the drive but start small and grow as needed.
The benefit of a virtual drive is that you can easily copy it. Just create a master image, copy it, test your project, and throw it away. This testing pattern provides a sterile environment for each test, yet it doesn't require any more time than a standard file copy.
You can extend the clean slate concept to multiple guest operating systems by just creating different master virtual disks. Test your installer on Linux, Windows 2000, and WinXP by just booting different virtual hard disks on the same host machine.
Training and Demos in the Field
Of course project development is not the only use for virtualization. A virtual machine with a configured virtual hard disk serves as an excellent training platform as well. The disks can be easily replicated and destroyed as required. As a trainer, you know that every student's machine is configured in exactly the same way, since they are all copies of the same master image. Constraining the student to a VM prevents destruction to the host operating system, which translates into more uptime for a training facility.
A recent project I was on used a virtual disk as a preconfigured demonstration platform. The sales team (or the poor engineer paired with a salesman) could grab a copy of the demonstration disk and the virtualization software and hit the road. The use of a preconfigured system limits the downtime of waiting for an engineer to build the system and reduces the occurrence of configuration errors in the field.
Which VM Software Is Right for Me?
The first important act of adding virtualization to your toolbox is choosing the virtual machine software you want to use. You have a few choices here, with the two major contenders being Microsoft Virtual PC and VMWare Workstation. A third, less obvious choice is User Mode Linux (UML). Each of these products has its own pros and cons (which are beyond the scope of this article), but ask yourself the following key questions when choosing a product:
- Which operating system(s) will run on the host machine? Virtual PC runs on Windows and OSX, VMWare Workstation on both Windows and Linux, and UML on only Linux.
- Which guest operating systems will I run? Virtual PC and VMWare work with most, although they have a small "officially supported" operating system list. UML runs only another Linux kernel.
- Will I migrate the guest machines to a server or enterprise product? Both Microsoft and VMWare provide server products that can use virtual disks from their client products. If your enterprise is already using a server product, choose a client product to match.
- Does my enterprise already have a license to a product? Many developers do not realize that most MSDN subscriptions include access to Virtual PC. If you have a subscription, check if you already have access to a product license.
|Figure 2. Virtual PC Guest Machine Configuration Dialog|
A few other up and coming virtualization products are available, but many are not mature enough to use in a production environment. The more mature products, like Virtual PC, include simple configuration dialogs that let you configure many pieces of the guest machine's hardware, as shown in Figure 2.
Integrating a virtual machine may appear tricky at first, but remember that it is just another machine on the network. Smart use of shared folders or a network file system (NFS) can allow you to easily share data between guest machines or between the guest and host machines. If you use MS Windows as your guest operating system, don't forget to look at the sysprep tool for preparing the operating system for reuse. Forgetting to do this can cause problems if you use the virtual machine in a networked environment.