I’m a big fan of using Virtual PC for both developing and prototyping new software – enabling me to try new and untested stuff, while leaving my main laptop intact for Email and Office. While Virtual PC isn’t a match for the raw power of a separate development workstation, it’s phenomenally portable and useful for customer visits, demos, and the like.
During the last few years of using the product I’ve gone through many setups, run a variety of Guest operating systems, and learned a lot in the process. I’ve compiled the following Top Ten Tips for using Virtual PC 2004 based on my experience. If you are looking to use the product (or are already using it), I hope there is something useful in here for you. I’d also like to hear what I can add from other people’s experiences…
10. When you create Virtual PCs, keep an eye on the size of your VHD file! It will automatically grow as you install new stuff on the Virtual PC, but will never shrink. Compress when the size of the VHD is significantly larger than the usage reported in the Virtual PC. To compress effectively, (1) defrag the disk in the Guest OS, (2) replace the spare space on the disk with binary zeros (using a third party tool such as cleanspace) and (3) run the compact hard disk wizard. Always remember to backup your original VHD before doing this!
9. Although Virtual PC additions is not supported for Linux images, you can replicate some of the functionality. You can use Windows SFU (Services for Unix) or SAMBA to cross mount NFS/SMB drives between the Host and Guest OS. To add time synchronization support for the Linux image, set the Host PC up as an NTP server (automatic in Win Server 2003 – registry switch in Win XP) and use virtual networking to sync using NTP. Remember to open up the NTP port on the Firewall of the Host OS beforehand!
8. On all your Virtual PC images, mount C:\ (on the guest) to Z:\ (on the host) by default. This will give you easy access to files on the host when needed (e.g. Z:\Temp, Z:\Windows). This shared folder functionality was shaky with earlier versions of VPC, but has been rock solid for me since SP1.
7. Use the Junction tool from sysinternals.com to create a junction called C:\Desktop on the Host operating system. Point this to your desktop (e.g. C:\Desktop -> C:\Documents and Settings\sguest\Desktop). In conjunction with Tip #8, you now have a very easy way of accessing the Host desktop (Z:\Desktop) from your guest OS. Same for Music, Photos and other folders that you may have setup.
6. Check out the command line options for “Virtual PC.exe” by running “Virtual PC.exe -help”. You can start, pause, resume, resize and change other image settings from the command line. This is handy when creating demo scripts that use multiple images – or starting and stopping a Virtual PC when you are away from the machine.
5. A dual monitor configuration makes an ideal setup for having your normal desktop on one screen and a running Virtual PC image running on the other. Be aware though that you can’t run the Virtual PC image full screen in this configuration – it will have to be windowed. (Virtual PC will come out of full screen mode as you use your Host desktop).
4. Confused about whether to use Virtual PC 2004 or Virtual Server 2005? If you want advanced scripting, VPC monitoring/administration or are looking for server consolidation, Virtual Server is for you. If you can’t live without drag-and-drop and sound support for your Guest OS, you’ll want to stick with Virtual PC 2004.
3. When you are creating Virtual PC’s, try to consolidate by function – not by product. This will help you maintain the number of Virtual PCs you run. For example, if you want to play around with the Beta of Visual Studio 2005, try to create an “DEV” or “PROTOTYPE” image as opposed to a “VS2005” image. This will help you control the number of VPCs you run.
2. When setting up your Virtual PC’s, start with 256Mb and then increase as necessary. If you are running a J2EE application server (e.g. WebSphere or WebLogic) I would recommend 784Mb. Also try and have your VHDs reside on a disk other than your system drive. This separation will help I/O throughput to the Guest OS – that, together with lack of physical RAM, tends to be the main reason for poor performance.
1. Get your images networked! I recommend two networking cards on each Virtual PC image – one bound to your main adapter, the other bound to a loop back adapter. You can configure this through the settings dialog when the VPC is shutdown. The first one should be used for connecting to the Internet – and will probably obtain it’s IP address through DHCP. Create a private class C IP network for the second (e.g. 192.168.0.x) – bind them all to a loop back adapter installed on the Host OS – and create a common c:\windows\system32\drivers\etc\hosts file for each image. Don’t forget to enable the ports on the Windows Firewall (the Advanced settings of the loop back adapter) to allow access to applications that you are sharing!