VMware: A Virtual Reality Machine
Sometimes, you need to use an application that just doesn’t run under Linux — even with the help of Wine. For example, one of us has to use a trouble-ticket system to fix customers’ problems. The problem is that the trouble-ticket application doesn’t run under Linux, with or without Wine. That author must then install both Windows and Linux on his computer (a dual-boot system) or else maintain a separate one for the sole purpose of running the single application.Nothing is wrong with using a dual-boot computer, of course. But it’s sort of a waste of time if all you need to do is run one or two applications. Dual-boot computers also have to be rebooted when you need to use the other operating system. An alternative to dual booting is VMware, a commercial product from VMware, Inc. This program creates a virtual computer within a physical computer. The virtual computer runs as an application, just like OpenOffice or Mozilla.VMware looks and works just like a real PC. The virtual VMware PC can run an operating system, such as Linux or Windows, just like any real computer can. The operating system running on the virtual machine behaves just like the real operating system. Any applications it hosts, therefore, look and work just like the real applications!TipVMware is also good for writing Linux books. Writing techy books like this one requires you to use early beta versions of new releases during the initial draft phase. The old method required installing the beta on your computer and using it for both testing and writing; alternatively, you can use two computers side-by-side. Both methods are clunky and cause numerous headaches when the beta does some funky thing. VMware solves the problem by allowing you to run the current production version of Red Hat Linux on your host computer and install the beta on the virtual computer. You can test the beta to your heart’s content while writing at the same time in OpenOffice — all on the same virtual computer. Updating from one beta version to another is a snap too.You can download the VMware Workstation product for free. It requires a license that costs approximately $300 for commercial use and $100 for educational use. It’s money well spent.VMware networking
The VMware virtual computers can use your host computer’s network connection. VMware provides two methods for accessing a private LAN and one method for accessing the host computer’s local file system:Bridged network: “Bridges” the virtual machine to the host machine’s private network through the host’s network interface card (NIC). The virtual machine appears to be an independent network device to the LAN. The virtual computer has its own virtual NIC with a real IP address. The bridged configuration provides the most flexible network configuration possible to the virtual machine. However, the virtual machine must be configured and maintained like any other device.Network Address Translation (NAT) network: A process that makes one networked computer appear as another computer. NAT translates the source network address (and port) to that of another address (and port). This method is widely used by private networks to funnel all their hosts through a single gateway to the Internet.VMware uses NAT to make the virtual machine appear to be the host machine on the host machine’s LAN. NAT is easy to configure because you have to configure only the virtual machine’s network configuration to use the dynamic host configuration protocol (DHCP). You have to select only DHCP, therefore, and nothing else. (We describe NAT in Chapter 16.)Host-only network: Configures the virtual machine to use the host machine’s file system. VMware sets up Samba on the host machine, and then the virtual machine can mount the host’s file system. (Samba is a Linux/Unix system that speaks the same protocol, or language, as the Microsoft file sharing system. Samba allows Linux computers to access file systems on Windows computers and vice versa.)
VMware also offers a 30-day evaluation license for no charge. The temporary license, which isn’t limited in any way other than the time limit, is ideal for testing this powerful tool. The steps in the following section describe how to download the product and its temporary license to find out about its power.
Downloading VMware
VMware, Inc., allows you to easily download and use its software. These steps describe the process — virtual computing for everyone!
Log in to your Red Hat Linux computer, open the Mozilla browser, and enter www.vmware.com/download in the text box.
Under Desktop Products, click the Download button.
The VMware Workstation 4 window opens. You need to obtain a temporary license to use the software.
Click the Evaluation Serial Number link.
The Try VMware Workstation 4 window opens.
Click the Register button and the registration form opens.
Fill out the form, making sure to fill all boxes marked with a red asterisk.
Click the Continue button and your browser goes to the Download page.
Click the Download Binaries for Linux Systems link.
Read the VMware End User License Agreement and click the Yes button.
You see the Download VMware Workstation 4 (for Linux Systems) link. You can download from several sites across the globe.
Click on the RPM version from the site closest to you.
The Enter Name of File to Save To dialog box opens.
Click the Save button.
The VMware-workstation RPM file is saved to your home directory.Tip You’re not limited to saving this file or any other to your home directory. You can select any location in which you have write permission. For example, you may want to save to the /tmp directory.
Click the Evaluation Serial Number button.
Click the Register button and enter your name, e-mail address, and other information in the form that’s displayed.
Make sure that you specify Linux in the Product Host Platform section. After you complete the form, the evaluation license key is e-mailed to the address you provide.
After you download the software and evaluation license, read the following section to install the software.
Installing VMware
After the VMware software is downloaded, you only need to install it. The software, provided in Red Hat Package Manager (RPM) format, is self-installing; you can read more about working with RPMs in Appendix D. These steps describe how to unpack the RPM package and install the license:
Open the Nautilus file manager by double-clicking the Home icon, in the upper-left corner of the desktop.
Right-click the VMware-workstation RPM package file and choose Open WithInstall Packages.
A Query window opens and prompts you to enter the root password if you’re not logged in as root.
Enter the root password, if you’re prompted.
The package manager checks the state of your computer and opens the Completed System Preparation window.
Click the Continue button and the VMware-workstation package is installed.
When the window disappears, VMware Workstation is installed.
Installing Linux kernel headers
VMware makes use of Linux kernel modules, which are similar to Windows device drivers, to interact with the host Linux computer. VMware ships kernel modules that automatically work with some versions of Red Hat Linux. However, we can’t be certain that those modules match your Linux kernel — the one that ships with this book. Therefore, the following steps help you build your own VMware kernel modules.Building VMware modules requires the presence of Linux kernel headers, which may not be installed on your computer. You need to install the headers by installing the Linux kernel source RPM package. Follow these steps:
Insert the companion DVD into the DVD-ROM/CD-ROM drive.
Click the GNOME Menu button and choose System ToolsTerminal.
If you’re not logged in as root, run the following command:
su -
Enter the root password when you’re prompted.
Enter the following command to install the Linux kernel headers:
rpm –Uvh /mnt/cdrom/RedHat/RPMS/kernel-headers*
The kernel source package is installed and you’re ready to configure VMware.
Configuring VMware Workstation
This section guides you through the process of building (if necessary), installing the correct kernel modules for, and configuring any or all of the virtual networking connections. After completing this section you have a running virtual PC capable of running both Linux and Windows workstations.
Starting the VMware configuration process
This section describes how to get the started configuring your VMware virtual PC. The following steps describe how to use the VMware configuration script.
Log in as the superuser (root).
Click the GNOME Menu button and choose System ToolsTerminal.
After the terminal emulator window opens, enter the commandvmware-config.pl in the terminal emulator window.
The vmware-config.pl script displays the VMware license agreement.
Press Enter to start displaying the entire agreement, and keep pressing the spacebar to display each new page.
Assuming that you’re a lawyer and know what you have just read and accept it, type yes and press Enter when you’re prompted.
The configuration script tries to locate an existing module for your version of Linux. If the script finds the correct module, skip over to the “Configuring VMware networking” section. Otherwise, read the following section.
Building VMware kernel modules
In case the VMware Workstation package you installed doesn’t have the correct kernel module, you have to create one. The following steps describe how to create your own VMware kernel module.If the kernel modules shipped with VMware doesn’t match your kernel, you see the following text:
None of VMware Workstation’s pre-built vmmon modules is suitable for your running kernel. Do you want this program to try to build the vmmon module for your
system (you need to have a C compiler installed on your system)? [yes]
Press Enter to accept the default Yes answer.
You then see text describing your C compiler (a compiler is software that translates human-readable computer code into a form that computers can understand).
Accept the GNU C compiler gcc by typing yes and pressing Enter.
The vmware-config.pl script shows you where it found your kernel header files:
What is the location of the directory of C header files that match your running
kernel? [/lib/modules/2.4.20-8/build/include]
The exact module version number and location vary, depending on the version of kernel headers package you installed. The value, however, should be correct.
Press Enter.
The configuration script proceeds continues to create the kernel modules it needs. After it finishes, it prompts you to configure VMware networking.You’re prompted to configure VMware networking.
Configuring VMware networking
This set of steps describes how to configure VMware networking:
We assume that you want to use virtual networking, so press Enter. The script automatically configures both bridged and NAT networking.
Remember Bridged networking doesn’t work if the host computer uses a wireless NIC. NAT works on wireless NICs, however. This limitation should be fixed eventually.
Answer Yes to allow the script to probe for unused subnetworks.
You need have to accept the DHCP license, so type yes and press Enter.
The DHCP license is stored in /usr/share/doc/vmware/DHCP-COPYRIGHT. The license makes for good reading.
Optionally, type yes and press Enter to use host-only networking.
Host-only networking consists of a virtual network interface that communicates with only the VMware host computer (the one you’re configuring now). Host-only networking is used primarily to share the host’s file system with the virtual computer.
Type yes and press Enter when prompted to probe for an unused subnetwork (for the host-only networking).
We’re assuming that you will, or may want to, share files from your host computer (Linux) to your virtual computer (Linux or Windows). You can answer No here if you don’t want to share — but then your mom may get mad.
Answer No when prompted to configure another (second) host-only network.
Answer Yes to allow the system to automatically access the host file system.
The installation script wants you to accept the Samba license. (Samba is used, in this case, to share Linux files with virtual Windows and Linux computers.
Press Enter to accept the license.
The Samba license is stored in the /usr/share/doc/vmware/SAMBA-LICENSE file — more interesting reading).
The installation script starts the VMware daemons (programs that run continuously in the background to provide system-wide services) and asks whether you want to share files with the virtual machine.
Press Enter.
Enter the username and password of an account on the host machine.
For example, you should enter the username and password of your Linux account. When the script prompts you for your SMB password, use your Linux password.
You’re prompted to enter additional usernames and passwords. Enter yes if you want to do so. Otherwise, press Enter to accept the default No answer, and the configuration process ends.
The VMware server is now configured on your host machine. The vmware-config.pl script starts up the virtual machine processes when it finishes. You can rerun vmware-config.pl whenever you want to reconfigure VMware.
Installing an operating system on a virtual computer
VMware is great at providing a platform on which to run other operating systems under Linux. You can install either Windows or Linux on your virtual PC. After you install and configure VMware, you can run and use your virtual PC.This section describes how to install Linux on your new VMware Workstation. We use Linux because we can’t include Windows on the companion DVD or expect you to go out and purchase that expensive puppy. (We asked Microsoft whether we could bundle its operating system, but we never heard back about it. Not until recently did we realize that it uses a different license from Linux. Just kidding!) Because we can, and already do, bundle Red Hat Linux, we can easily show you how to install it. However, if you have a legal copy of Windows, go ahead and install it.
Creating a VMware icon on the GNOME Panel
You start the installation process by first creating a GNOME applet that you click to start VMware. This action makes starting VMware a breeze. Follow these steps:
Right-click the Gnome Panel and choose PanelAdd to PanelLauncher.
Enter, on the Name submenu, the name you want to call your icon; for example, VMware.
Enter any information you want in the Comment field and then type /usr/bin/vmware in the Command field.
Click the Icon button and a selection of numerous generic icons appears. Select any one that tickles your fancy.
Click the OK button. The new launcher appears on the GNOME Panel.
Starting your virtual machine
Now, you use the new icon to start your VMware virtual machine. The following steps describe how to start the machine:
Click the VMware icon and the VMware Workstation appears.
You need to enter your evaluation license serial number, so choose HelpEnter Serial Number.
Enter the temporary serial number that was e-mailed to you. Also, enter your name and, optionally, your company name.
Click the OK button and then click New Virtual Machine.
The New Virtual Machine Wizard opens. The default setting should work for you, so you don’t have to make any changes.
Click the Next button, open the Guest Operating System pull-down menu, and choose Linux.
You can safely accept the default settings in the next set of steps.
Select Use Network Address Translation (NAT) when you see the Network settings window and then click the Finish button.
Congratulations! You have started your first virtual computer.
Installing Red Hat Linux on your virtual machine
You have your virtual machine running, so what can you do with it? You can install Linux and Windows and on it. The next step in the process installs Red Hat Linux on that virtual computer:
Insert the companion Red Hat Linux DVD.
Alternatively, insert a Windows CD in the drive, if you have one. Proceed through this set of steps and substitute the Windows installation process where appropriate.
Click the Power On button.
The VMware workstation starts up. You see the BIOS menu, just like you do on a real machine. The virtual computer should detect your Red Hat Linux CD and start the installation process, just like in Chapter 3.
Install Red Hat Linux. The installation process is the same as we describe in Chapter 3.
Technical Stuff VMware uses simple Linux files on the host machine to simulate the virtual computer’s disk partitions. (You have the option to use a separate partition for the virtual computer, but the most common method is to use the host file.) Installing an operating system (OS) on a VMware virtual computer places the operating system’s virtual disk on a file. Therefore, you don’t have to worry about harming your host computer whenever you’re installing a virtual OS. Any problems you encounter during the installation or use of the virtual OS are limited to the host computer files. The files used for the virtual OS are labeled with the .vmdk suffix.
When you’re prompted for the network configuration, select DHCP.
Using DHCP shortens the network configuration process because you don’t have to select a static IP address, netmask, and other parameters.
When you finish installing the operating system, click Reset.
Your virtual PC reboots and you have a fully functional virtual computer running Red Hat Linux. Cool.
Experiment with your newfound tool. Virtual machines provide you with a new killer application that can be used to do almost anything you want it to do. You have an exciting, fun, and powerful device.Technical Stuff VMware creates not only virtual computers, but also virtual networks. Each virtual computer you configure to use bridged networking connects to a virtual switch. If you create two virtual machines on a single host, therefore, each machine can communicate with the other — and the host itself — as though they were connected to an Ethernet hub. This capability allows you to create experimental and production virtual networks. For example, you can use a single powerful PC to create several virtual servers rather than purchase and maintain individual ones. Cool.Tip Plex86 is the open source world’s answer to VMware. The Plex86 system provides a virtual computing platform similar to VMware in function. Plex86 works, but at the time this book was written was still in alpha development — it cannot run production systems. We encourage you to experiment with the system, which you can find at http://plex86.sourceforge.net.