Cover V10, I03
Article
Figure 1
Figure 2
Sidebar

mar2001.tar


Using VMWare as a Development Tool

Brian Wilson

I set up my first Linux system in 1992 as a lark. I was a SunOS and Mac lab manager at the time, and the idea of a UNIX system of my own appealled to me. Three weeks later, I started using it for consulting and telecommuting, and have relied on it ever since.

When I telecommute, I need to have at least one system at home running and ready for real work. I must be certain that I don't take my main system down when I experiment with new kernels, alternative operating systems, or different Linux distributions. I usually have a "hacker" computer around cobbled together out of my junk box, but it's a couple generations behind state of the art, and not much fun to work on.

I have tried dual boot setups; I keep Windows 95 and Linux on my laptop. Dual boot works, but only if the OSes involved play well together. I am using removeable hard drives for some things, however, only one OS is usable at a time. With multiple computers comes the nuisance of dealing with multiple keyboards and screens, unless you get a KVM (keyboard/video/monitor) switch. A good KVM is indeed a worthy investment. Given all this, the ideal setup for me is to simultaneously run multiple operating systems on the same computer, and that's where VMWare comes in.

Some Terminology

VM stands for virtual machine. A running copy of VMWare pretends to be a complete, standardized PC. It provides an environment that acts like an Intel x86 PC with an IDE hard drive, ATAPI CD-ROM drive, AMD Ethernet card, floppy drive, and serial and parallel ports. It has support for a sound card but I have not tried it yet. It does not matter what your real hardware is; VMWare maps your real hardware to the virtual devices. For example, if you have a 3Com Ethernet card, it still looks like an AMD card to the virtual machine.

When a VM is in the "power off" state, you can change some configuration settings, such as the amount of RAM it will use and which virtual devices will be available. You power on a VM by clicking a button; then you can watch the full boot process just like any PC. See Figure 1.

The host operating system is the operating system that is installed as your primary operating system. I run Red Hat Linux, and thus I use "VMWare for Linux". The guest operating system is the system that you install in a virtual machine. There is an officially supported list of operating systems, which includes the MS Windows family, Linux, and FreeBSD. My attempts to run other operating systems (Solaris and BeOS) under VMWare have failed. I would guess that close variants from the BSD family (OpenBSD and NetBSD) would work, but have not tried them yet (see sidebar).

Jumping on Board

When version 2 of VMWare came out, I downloaded and tested evaluation copies of it in both its Linux and NT incarnations. When the 30-day trial period expired, I paid for a licensed copy of "VMWare for Linux" and dumped the NT version. "VMWare for NT" works, but I did not find it as satisfying.

Each VM uses a configurable amount of RAM when it starts. I find 64 MB sufficient for a desktop Linux system. Therefore, to run one guest OS, I'd want at least 128 MB (64 MB for the host and 64 MB for the guest). I currently have a total of 256 MB, so I can easily run three VMs at the same time. Once a VM has started, the RAM is not dynamically allocated/freed; you must power down the VM if you want the guest OS to have more or less space.

Each VM uses a maximum of 2 GB of disk space; you set the limit when you initially configure it. It's possible to move beyond the 2-GB limit by using raw disk partitions. I have never tried this, because I have never found 2 GB to be a limitation. When I want extra storage space, I share it with the host operating system via Samba or NFS. This is more convenient, anyway; I keep my home directory and sources in the host disk space and share it among all the guests.

When you create a new VM, VMware creates a subdirectory with three files in it. One is the configuration file, which is a text file. The second is non-volatile memory that holds BIOS settings for the VM. The third file is space that holds the virtual disk drive. I usually ask for the full 2-GB partition when creating a VM; unlike a raw disk partition, the actual disk space is not used until you need it.

What's It Good For?

The most common and most obvious use for VMWare is probably that it lets you run application software not available for your host operating system. If you run Windows or Windows NT as a guest, then you can load up and run Office 2000, for example. So far, every application that I have tried works. I run programs that use the serial port to a digital camera and to a GPS receiver. I run Microsoft Access and use it to talk to the MySQL database server running in the Linux space. I can connect to NT fileservers running on other systems across the Internet.

Additionally, I run Linux in VMs. Why would anyone want to run Linux in a virtual machine on a Linux system? Let me give you some examples:

1. I can develop a single floppy Linux system (like one from the Linux Router Project or a rescue disk) using the full suite of development tools available on my main system, write it to the floppy, and then boot from the floppy in a VM. I can boot and reboot the VM without the nuisance of rebooting the real computer; and while the VM test OS is running, I still have full access to the development system tools.

2. I build and test experimental Linux kernels out before committing to them in the real system. For example, I might try out a 2.4 kernel to see how it works. The only trick here is that the hardware specs are different; make sure you get support for both your real hardware and the VM hardware into the kernel if you plan to use it on your real system.

3. I can test network code. This is very handy for testing firewall and masquerading setups -- all on a single computer.

4. I upgraded to Red Hat 7.0 on my home machine, but the servers I maintain will be at Red Hat 6.2 for the next few months while I wait for 7.1 to come out. Because Red Hat releases new libraries when it does major releases, anything I compile under 7.0 cannot be uploaded to my servers. By setting up a VM with 6.2, I can continue to maintain my servers. I can do compiles and test code in the VM and then upload to the servers. I can also selectively load newer packages from 7.0 into virtual 6.2 to test them.

Save Yourself Some Work

Here's a time-saving tip when doing system testing. Let's say you just installed Windows NT 4.0 as a guest OS and then put in Service Pack 6 and maybe the full Office 2000 suite, too. You have now invested several hours. Before you go any further, shut down VMWare and make a copy of the new directory that it created. (VMWare normally keeps all its files per user in a directory that you choose the first time you run it.) You can just do a compressed tar (such as tar czvf nt4.tar.gz nt4).

Now you have a clean backup of the entire virtual machine. You can do anything you want to the virtual NT system and restore from the tar file to get back to the fresh system.

You can also create additional VMs without going through the process of installing from distribution media each time. While working on this article, I installed Red Hat 6.1 and did a few customizations. I then shut it down and copied the entire directory to a new location. I edited the new copy of the *.cfg file with a text editor, changing references that pointed to the old directory to point at the new one. I then launched both the original and the copy in separate copies of VMWare. Voíla! Two separate machines, each running on a different IP address. This is much faster than installing Red Hat from CD-ROM every time I want to run a new test (see Figure 2).

Running Multiple Operating Systems

When you run more than one copy of VMWare, some of the real hardware devices cannot be shared. For example, only one virtual machine can be connected to the the floppy drive at a time. With VMWare 2.x, Windows 98 wants to have exclusive access to the virtual /dev/rtc (real-time clock) for performance reasons. So, I try to start it first when I also need to run additional guests. When you start additional VMs, you will see several dialog boxes warning you about what resources are being disconnected.

The most important connection is the network, which can be shared among all the VMs. VMWare comes with its own DHCP server, so if you set up each guest OS to act as a DHCP client, then you won't have any address conflicts when running several guests at the same time. I set all guest OSes to mount filesystems from my host, using either NFS or Samba, so I can have common home directories accessible everywhere.

Conclusion

I am a strong believer in the power of open source software, but after evaluating VMWare, I decided it was definitely worth owning a copy. If you already own a copy, I hope that I've provided a few ideas on new ways to use it. I recommend that you download an evaluation copy and at least try it out.

Resources

VMWare home page: http://www.vmware.com

Brian Wilson is currently build/release engineer at Coactive Networks in Sausalito, where they are developing Internet gateways for home control and telemetry systems. He has a B.S. in Computer Science and more than 16 years experience as a programmer and UNIX sys admin. You can reach him at: bwilson@clickshift.com.