irtual PCs are extremely useful for development, testing, and setting up deployments that require applications to be isolated from one another. During the past year or so, I’ve built more than a dozen Virtual PCs with Microsoft Virtual PC 2004, and used a few more that Microsoft supplied with the product.
Because developers need to replicate their customers’ problems, the ability to run their software in the same environments as their customers is important. If you develop on Windows XP, and a customer discovers a problem on Windows 98 Second Edition, it helps you immensely to have a Windows 98 SE installation.
Several years ago, I filled my office with computers running different operating systems. As long as I was trying to cover only the gamut of Windows desktop systems localized for US English, I was able to keep up. Once I expanded my spectrum to cover servers, systems localized for a variety of countries and languages, and a variety of Linux distributions, coverage on a one-computer-per-system basis became impossible.
Just when I began pricing removable hard disks, Microsoft acquired the Virtual PC product from Connectix and re-released it under its own name. Since Virtual PC was covered under my existing MSDN subscription, it was easy for me to try it out, and I never needed to look at VMWare’s products.
Installing an operating system on a Virtual PC is just as much work as installing it on a real PC, at least the first time. Once the Virtual PC (VPC) is built, however, the advantages become obvious: you can clone the VPC, back it up, perform experiments on it, restore it, and even distribute it to others.
For example, Microsoft gave reviewers and testers a DVD containing a VPC configured for “Indigo” development during one of the beta tests. Installing all the software for this configuration onto a virgin machine would have taken eight hours; installing the VPC took only 20 minutes. When the testing was over, deleting the test environment was just a matter of deleting the directory, which took a minute or two. Compare that with the two-day “scrape your computer down to the bare bits and reinstall from scratch” process that Microsoft recommends for installing the release version of Visual Studio 2005 over previous betas.
|What You Need
|Microsoft Virtual PC 2004
SuSE Linux 9.1 Professional
Walkthrough: Installing SuSE
To give you an idea of what building a Virtual PC involves, this tutorial walks you through a Microsoft Virtual PC 2004 installation of SuSE Linux 9.1 Professional from DVD. It uses Virtual PC 2004 SP1, installed on Windows XP SP2. The host computer has 1 GB of RAM.
Start by creating a VPC:
The New Virtual Machine Wizard will come up:
You want to create a virtual machine:
I usually name a virtual machine by the operating system I’m installing (in this case, SuSE 9.1 Professional):
If you later clone the VPC, use a name that indicates the special purpose of the clone. I briefly experimented with maintaining simple numbered clones, but found that after a week or so I couldn’t remember which number had which software version.
The New VM Wizard knows the memory needs of 11 specific Microsoft operating systems, ranging from MS-DOS to Windows Server 2003. As it says on the page, you can choose Other for anything else:
The Wizard tends to recommend less memory than you’ll want for most systems, but you can change it now, and also adjust it later. To install SuSE Linux, allot 256 MB of RAM, at least for now:
Later, you might decide to run the VM with less RAM to allow more processes to run in the host machine, or you might decide to run the VM with more RAM to accommodate the memory needs of the applications you are running in it.
Since you are installing the system from scratch, create a new virtual hard disk:
If you were cloning an existing VPC, you’d use a copy of the existing virtual hard disk file.
The default hard disk name is usually fine for a new VPC:
You now have a VPC that’s ready to run, but it has an empty, unformatted hard disk:
You need to boot it from a physical CD or DVD, or an ISO CD or DVD image file. The CD menu on the Virtual PC shows that you’ve already captured the physical D: drive. The boot information from the VPC’s BIOS shows that it sees 256 MB of RAM, just as you set it:
With a SuSE installation DVD booted, you get a menu of options. Choose a normal installation:
From this point on, installing to the Virtual PC is almost exactly like installing to a physical PC. In YaST, SuSE’s OS setup and configuration tool, you pick your language:
And you accept the default installation settings:
YaST does not automatically detect the emulation sound card. So ask it to detect older sound chips, and it will find the emulation Sound Blaster 16:
Working with the SuSE VPC
Two or three hours of automatic installation later, you can boot SuSE Linux:
As you might expect, the support for Linux in Virtual PC 2004 is not as complete as the support for Windows. To release the mouse from the Linux VPC window, you must press the right Alt key. On a VPC that runs Windows, you can move the mouse focus in and out of the VPC window smoothly and transparently once you have installed the Virtual Machine Additions:
The Virtual Machine Additions also allow the emulation of a video card with more memory, allowing for better video modes. They further support sizing the VPC window interactively with the mouse to nearly arbitrary sizes, as well as sharing folders between the host PC and the VPC:
You can work around the lack of shared host folders. SuSE, like most modern Linux builds, can view Windows networks using Samba, as long as you don’t block the Samba ports with a firewall. I have a Linux build of ActiveState Komodo on my host Windows machine, and I have shared the directory over the Windows network so that it can be seen from Linux with Samba:Once I copy the license file to my VPC, I can run it in a shell:
If I had installed a firewall that blocked Samba, I could still transfer the file. I would use Web sharing of the folder on the host Windows PC and view the directory from the Linux VPC using a Web browser.
Transferring the compressed installation TAR is a similar process. Once you’ve transferred it to the Linux VPC, you open it with the default archive management tool and extract it to a new directory:
Then you install the software. In order to do so successfully, you need to take root privilege temporarily:
Once the software is installed, you need to exit the privileged shell to run under your own ID, since you have installed a license for only your user account. You can either create a link or put the installed software on the path to make it convenient to start from a shell:
SuSE installs Perl, Python, and Tcl by default, and Komodo detects all three. SuSE also installs Java, but Komodo is not a Java editor. SuSE does not install PHP by default, but you can download and install it from php.net using the built-in Web browser, just as you would for a SuSE installation on a physical PC.
Just like that, you have configured a complete installation of SuSE 9.1 Professional Linux in a Virtual PC and installed development tools. Now you can use the Virtual PC for Linux development and testing. You also can save the disk image on a DVD+R or other media, enabling you to revert to this configuration quickly in the future.
Tips I Wish Someone Would’ve Told Me
The following tips can save you time and aggravation when working with Virtual PCs. Use them to get the most out of your VPC investments.
1. If you are installing a Windows OS in a Virtual PC, you can save yourself at least half an hour by doing a quick format of the virtual hard disk instead of a full format. What you’re skipping is the extensive testing that the format utility does to find bad disk sectors. It’s not a real disk, so the testing is essentially useless?assuming that you have a reliable physical hard disk on your host computer.
2. When working with Virtual PCs, you have the option to turn on “undo” disks. This option allows you to experiment with a VPC and decide at the end of your session whether to commit your changes to disk or return the disk to its original state. It’s not as great as it sounds.
In my experience, undo disks slow the VPC down to a crawl. Instead, you can “clone” a VPC. For example, if you have an existing Windows XP VPC, you can copy its hard disk image file to a new VPC. If the experiments you do with the cloned VPC work, you can make that your new base VPC and delete the original. If the experiments fail, you can delete the clone. If the experiments create a configuration you want to keep in addition to the base configuration, then you can keep both around.
3. Three factors limit the number of VPCs you can keep and run: disk space, RAM, and your time. Disk space is obvious: if a VPC takes between 500 KB and 5 GB of space on your host machine’s hard disk, it’s easy to chew up disk space by keeping too many VPCs live. Writable DVDs are a good way to store VPCs offline.
The RAM limit is not so obvious. You would think that VPCs could utilize the large virtual memory space of your host PC, but they are limited by the actual RAM in your host. For example, with the 256 MB SuSE VPC you created running, the host PC has only 450 MB of its total 1,024 MB of physical RAM available. With the VPC closed, the host PC has 750 MB of its physical RAM available. In other words, the VPC takes up all the physical RAM you allocated, plus about 45 MB. That makes sense, because emulating the hardware also takes some RAM.
What about your time? Just like a physical PC, a Virtual PC needs not only to be installed but maintained as well. The disk file needs to be backed up. The operating system needs to be patched. The antivirus needs to be kept up to date, and the anti-spyware solution needs to be kept up to date.
On the other hand, if a VPC gets a virus and you have been faithful about backing up the virtual hard disk, restoring to a clean backup is a snap: delete the infected image file and copy the saved disk image back from a DVD in just a few minutes.
4. If you’re planning to buy a new PC that will run multiple VPCs, include one or more big hard disks, a big backup, lots of RAM, and the fastest CPU you can get. The computer I use mostly for VPCs has 1 GB of RAM; I often wish it had two. It has a 160 GB hard disk; I often wish it had two of them and that they were even bigger. It has a DVD Writer that has worked out well for backup, but I often wish it also had a USB2 external hard drive.
It’s only money, but giving this machine the ability to run multiple VPCs eliminates the need to buy a whole bunch of other computers.