How to Run Windows and Linux on a Single System
VMware virtualization software lets system builders offer more functionality without higher costs. Here's how to get it working.
February 12, 2007
This Recipe will tell you how to install and optimize VMware Server, a software virtual machine emulator that lets you run Linux and one or more other operating systems at the same time, each in a separate window. In most cases this means Windows, though other OSes can be run as well.
Why do it? The disadvantages of Windows are well known. It's a malware magnet, and some reports say its instability has survived even into the recently-released Vista version. At the same time, Windows runs on the overwhelming majority of desktops and notebooks. It's a fact of life.
Recently, Apple Computer has started boasting of the Mac's ability to run Windows via dual boot. This capability is important, because many business programs and popular games alike are available only in Windows versions. Linux has the same problem. Many essential programs are simply unavailable in versions that will run on this open-source OS.
VMware Server makes it possible to not only run these programs, but also to run them from an open Linux session. So a user can work on a word-processor document in OpenOffice in Linux while they run a legacy Windows graphics application to create its images at the same time.
The Linux OS emulation described in this Recipe lets users run older legacy Windows applications within a virtual machine that's a lot more malware-resistant than a computer running Windows as its only OS. This emulation also lets users run the new Linux applications, many of which are as good or better than their Windows equivalents. Oh, and did I mention that they can run Windows and Linux applications at the same time?For example, I'm running Opera in Linux with 90 open sub-windows, something I wouldn't even want to try in Windows. I also have Firefox 2.0.0.1., since some Web sites have trouble with Opera, just like they do with Windows IE. All major Linux distributions come with an OpenOffice equivalent of MS Office, which are free and very, very good. I just downloaded gEDA schematics and PC Designer, which gives me what appears to be a complete electronics design package; the functionality includes rip-up-and-retry PCB auto-routing. For free software, that's not bad!
Linux emulation also gives users an easy transition from Windows to Linux. It does so by letting them run familiar Windows applications while experimenting with new Linux applications. So a user can run "best of breed" apps without caring whether the application runs on Linux or Windows. Also, a user can take advantage of a truly modern OS without the problems that new Vista users seem to be experiencing.
While you can run VMware Server with a Windows host, I don't recommend it. What this will mainly do is give the user a chance to see the "blue screen of death" take down both the Windows host and the Linux guest.
Also, there are three workstation versions of VMware: VMware Server, VMware Workstation, and VMware ACE. VMware Server is free, and it offers the ability to provide normal multi-OS functionality to Linux. VMware Workstation and VMware ACE provide extra functionality for program developers, such as the ability to allocate multiple CPUs to a single virtual machine and to set security policies for virtual machines. These two products are not free, however, and I believe the extra functionality is not useful for the typical user. To compare these products in more detail, view this VMware chart.
Mainstream x86 Multi-OS ChoicesThere are several ways a user can run Windows or other OSes from a Linux box. While I've found VMware Server to be an excellent solution for my own needs, other programs may fit your users' needs better.
Remember that all emulation applications slow performance and require extra memory over and above what the system would require running in native mode. I'm currently running an Athlon 3500+ with 1 GB of DDR2. VMware did run satisfactorily with a Duron 1800 with 512-MB DRAM and 3-GB swapfile. But it ran badly on that same Duron 1800 configuration with just 1 GB of swapfile. Hardware virtualization support (Intel VT or AMD-V) is desirable, but unnecessary for use with VMware Server.
Below is a list of other ways to run alternate OSes, along with the features that, in my view, present serious limitations:
Dual Boot:
The next application you need when working with a file always seems to be on the other OS.
It's impossible to cut-and-paste between applications running on both OSes.
Linux file access from Windows requires special utilities.
Free, but requires technical expertise to make it work.
For applications that don't work in emulation (such as some games), it requires absolute maximum performance from a computer.
Win4Lin:
Limited choice of workstations.
Not free. The current sale price seems to be about $70.
Win4Lin 9.x. can't be upgraded in terms of guest Windows OS and prevented upgrades past FC3. This makes hardware upgrades to modern hardware impossible.
Win4Lin Pro doesn't support a guest-host clipboard.
Only permits installing Windows.
Xen:
Lacks a guest-host clipboard.
Though downloadable from any mainstream Linux distribution via automatic installer, it requires some command-line work afterwards.
Requires CPU virtualization support.
Currently best for servers rather than workstations.
KVM Virtualization:
Requires CPU virtualization support.
So new, only developers know much about it.
Wine:
Very limited program choice. From my experience, it's flaky, too.
While MS Office works, the majority of Windows programs do not work and never will work with Wine or its commercial CodeWeavers counterpart.
VMware Installation
There are minor differences between Linux distributions that affect installing VMware Server. There are also many excellent Linux distribution-specific how-to's. Find a distribution-specific how-to that works for you. This Recipe isn't intended to replace them; rather, it's intended to show you how to optimize your system to make VMware Server / Windows as useful as it can be.
To start, get VMware Server here. Also, you can go to the registration page from there, but you'll need a registration number to complete your VMware Server installation.Get the any-any patch here. This inserts kernel modules required to support VMware Server.
When you run the VMware configuration script, it will ask for the directory name for VMware devices. Change the /var/lib/VMware/Virtual Machines to /var/lib/Virtual_Machines. The blank space will give you endless trouble when you try to access that directory from command line apps. When you're asked for a guest name in the guest configuration Wizard, it also doesn't need spaces; so, for example, use Window_98, not Windows 98.
After Installation of VMware Server
Whether your guest OS runs in VMware depends just as much on the guest OS configuration as it does running in native mode on a physical machine. If you have a USB problem, go to Windows and check Control Panel > System > Devices. Look for the same error icon you'd look for on a physical machine installation. Do this with audio, network, video, etc., and for drivers.
If you've got a previous VMware Server installation (perhaps you just upgraded the host OS or changed Linux distributions), just move the VMware .vmx and .vmdk file(s) into the corresponding place /var/lib/VMware/Virtual_Machines/ location. Then change ownership/permissions to your userID.Pull down the VM menu from the VMware Server Console to Install VMware Tools. This will improve your speed and stability. It will also give you access to the VMware audio and video drivers.
Guest host file transfers go through a virtual Ethernet card. The default provided with the system is an AMD PCNet PCI card. Its transfer rate on this system is about 400 Kbits per second. Replace that "card" with a Pro1000, and you can get that up to about 3 Mbits per second.
The VMware Server "virtual Ethernet card" is a single-line text entry in the vmx configuration file. Like a real card, it requires a Windows driver.
To get the required Windows Ethernet driver, download the Pro1000 driver: Win 9x, NT or Win2000+. I used the IBM Win98 site drivers. I don't know if the later Intel drivers will work the same for you in VMware. The Intel site I mentioned above has the most current versions, including one for Vista.
If your driver location looks like the following illustration (i.e., down a few levels of directory tree from C), you should create a shortcut to the driver file off C: drive.
For me, installing the driver required lots of swapping between the Windows OS disk and the driver. (This may not be true of Windows versions subsequent to 9.x.) A shortcut gets to the driver with two clicks:
Enter /var/lib/VMware/Virtual_Machine/Windows_98. Open the .vmx file with a text editor and insert this above the first line of the Ethernet section:
ethernet0.virtualDev = e1000
Save the file, and exit. Then, from Windows running in the VMware guest session, do the following:
Remove AMD network adaptor from Windows Start > Settings > System > Devices.
Reboot the Windows guest.
When it asks you to install a driver for a PCI Network Ethernet adaptor, hit Cancel.
Open Start > Settings > System > Devices. Look for a network device in Other that shows a problem.
Right-click the network device, then select Install Driver.
Go to "choose a card from a list" option (not "have disk"). Select "network device" and "have disk."
Go to Drive C: and go to your shortcut. Choose the .inf driver. Hit OK, and you should see a card list.
Select Intel Pro/1000 MT Desktop Connection. Then hit OK.
When it asks for the Pro/1000 install disk, go to your C: shortcut. When it requests the Windows disk, insert. Alternate until it stops requesting disks.
Click on Finish.
Reboot.
To change card settings, go to Start > Settings > Network > Intel(R) Pro/1000 MT Desktop Connection > Properties (button) > Advanced Tab > Link Speed and Duplex > Select Value = 1000mbps Autonegotiate " reboot after changing settings.
Setting Up Audio on VMware Server
A VMware Server guest can handle multimedia content and access the PC audio system to provide sound. If you're running a 64-bit host and a Windows Vista 64-bit guest, you can use the 64-bit VMware Server driver on the VMware.com site. Download it, put it in the Windows filespace, and install it as you would any other audio driver.
Everyone else should do the following:
Install this Windows sound driver as follows: Open Control Panel " Settings > System > Sound " Multimedia.
Delete all audio drivers.
Install the driver file.
Reboot. Find the .cat file (or other config file) the system asks for. It's in the pile of files the driver installs. Click OK.
Play an audio file.
Change KDE Sound admin settings to "autodetect." Then tell it to release the sound system after two idle seconds.
File Access To/From Guest/Host Via Samba
Samba is a collection of programs that collectively provide file and print services for Windows clients, making it possible for them to "see" Linux (and other) file systems as networked drives.
The most useful thing about a VMware Server Windows/Linux installation is its ability to use Windows legacy and native Linux applications on the same files. To make this possible, a filespace visible to both Linux and the Windows guest at the same time is required.
For instance, on my workstation, the Linux system sees /home/alizard/win/* as a directory tree. The Windows guest sees that directory tree as networked Drive E.
This isn't a Samba guide, because there are many books and articles on that. But here's enough to give you a quick start and get you working.First, make sure that Samba is installed on the system. It usually is by default, but check anyway.
In the following Samba configuration file, "Username" means your username. The user IDs should be the same for both Windows and your host. This configuration file basically defines the shared Linux-Windows environment.
For more information, go to the Samba man file:
$ man Samba
or go to the documentation at the Samba site linked to in the first paragraph of this section.Samba Configuration Setup for VMware Server
Open a Linux text editor as root, and save the following into it:
/etc/Samba/smb.conf
( ; means comment line)
[global];General server settingsnetbios name = FC6workgroup = workgroupwins server = 169.0.0.1server string = Samba Serverprintcap name = /etc/printcapcups options = rawlog file = /var/log/Samba/%m.logmax log size = 50socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=8192; SO_SNDBUF=8192dns proxy = noguest ok = yesguest account = usernamesecurity = userencrypt passwords = yesusername map = /etc/Samba/smbusers smb passwd file = /etc/Samba/smbpasswdrestrict anonymous = nodomain master = yespreferred master = yesmax protocol = NTacl compatibility = winntldap ssl = Noserver signing = Auto[win]path = /home/username/data/writeable = yesvalid users = usernamecomment = homeadmin users = usernamebrowseable = yes case sensitive = no
The "path" in the above configuration file should point at the Linux directory or directory tree that you want to be the shared Linux-Windows filespace.
When the new directory appears within the C: drive, right-click its icon in Properties and click "Map to network drive." (It will probably be drive E:) Once you've set up Samba on VMware Server, you may get this error message during startup: "Permanent connection not available. . . do you want to restore . . .?" If so, then click Yes. Next, check your shared folder / network drive from Network Neighborhood or Windows Explorer. If it worked to begin with, you should see the contents of the shared Linux/Windows directory right where you left them.
On a new installation, if you have a firewall installed, you'll know that Samba is up as soon as you see the following VMware ZoneAlarm alert:
As soon as you see that (assuming that it is in the "localhost" 192.x.x.x range), tell your firewall to permit NetBIOS access to that IP address. Open your firewall there, and you should see something like the following in Network Neighborhood:
Helpful SAMBA Hints
The following hints and tips will make the shared Linux / Windows filespace easier to use:
Make sure your Windows file tree hasn't changed from when you ran Windows in native mode. Put that file tree in a network drive created in Samba as described above. Move only those program files and data that can't be used by non-Windows applications onto the Windows virtual drive.
Because you don't have direct access to the virtual data files from Linux, to keep your data accessible by storing it in the Linux space and using a Network Drive/Samba to give Windows applications access.
On Windows Desktop shortcuts, right-click Properties on each icon, and change the drive letter from C: to E: on anything you didn't move into Windows but plan to keep using. Alternatively, simply do this every time you use another program from a Windows desktop icon.
Setting Up USB Devices (Printers, Scanners, etc.)
You can access a printer, scanner or other USB devices directly from Windows applications via VMware Server.
The following image shows the menu tree opened to where one selects specific USB devices for use with VMware Server. To select a device, click on the corresponding device menu entry. A checkmark will then appear on the menu next to selected the next time you open the menu:
To get to what you see here, from the VMware Server Console top menu: VM > Removable Devices > USB Controller > printer.
Here's how to get a USB printer working in VMware:
Open VMware Server.
Click the Windows tab.
Click on Add Device.
Add the USB controller.
Boot Windows.
From the VM toolbar, VM > Removable Devices > USB Devices > [your printer name].
Windows should show "installing new devices" and then demand you select a printer or "Have Disk." Pop in the CD (usually) containing your printer drivers.
Click OK. You should see a window showing files being installed.
Go to Start > Settings > Printers. You should see your printer.
Right-click the printer icon, and select Properties.
Click "print test page." Watch a printer test page appear. Close it, and you're done.
You can also get scanners and other USB devices to work, as well, by following the non-printer-specific part of the above procedure. For example, I got a Belkin USB UPS working in VMware. (Later, however, I realized that the software was of no particular use on a Linux host!)
The VMware virtual USB adaptor lets you operate two active USB devices concurrently. To attach a second USB device, follow the "VMware Toolbar" step above. A USB device can be used either from the Linux host or Windows guest; you have to choose which OS the USB device is to work with, and then change as necessary.Running a Printer from VMware Server
Disable the printer in Windows so it can be used in Linux by going to the VM > Removable Devices > printer menu item again. Then unplug/replug the printer's USB cable. Go to print manager, and stop/start the printer.
To switch USB printers between OSes, you may have to turn off the USB devices on VMware server, or even restart a device using unplug/plug. Then restart the CUPS Linux print system. Do this by going to the Linux Start Menu. Then open Control Center, click Peripherals > Printers, and click Printers from the top Printer menu. Finally, click Restart on the pulldown menu.
As for scanners, you might as well do this from Linux!
VMware Server occasionally drops Windows audio. If this happens, right-click the speaker icon on the bottom-right of the status bar of the VMware Server console. Then select Connect.
Hints and Tips to Improve VMware Server OperationHere are my top VMware Server hints and tips:
Disk speed: Most distros contain the safest, most conservative options for determining hard-disk speed. You may be able to double your HD access speed. You can find out more this Stanford University "Tuning the System" page.
Split your virtual drive (the flat file which is the VMware guest "hard drive") into a growable drive in 2-GB chunks. This will reduce your file size to the actual size of your files installed into the Windows virtual drive. I found this drastically increases access speed.
Most Windows tips and tricks also apply to Windows run in a virtual environment. Utilities will work the same way. You secure it the same way, with a firewall and antivirals. It's just like native mode for the most part, except that it'll crash less.
If a program on a network drive runs slowly or oddly, reinstall it in Windows to get it to run at acceptable speed. I had to do this with Eudora, MS Office, CorelDRAW, and Paint Shop Pro. If you have a native C:/Program Files on an original Windows installation that is being moved to a VMware Server guest, move Program Files to the virtual Windows drive. Don't leave it on Drive E: (i.e., /home/username/win).
Split the Virtual Disk for Higher Speed and Easier Backup
Before starting this part, find VMware hints and tips in the Reference section below, as it covers command line utilities and where to get them. Next, the following command does the actual splitting of the virtual disk using a VMware Server command line utility:
# VMware-vdiskmanager -r sourceDisk.vmdk -t 3 destinationDisk.vmdk
Once done, change the permissions:
chown username:username *.vm*chmod 777 *
Open the original *.vmx file. Make sure it points to the first of the series of split files the flat file originally created will become. VMware-associated files are listed in this text file: /etc/VMware/locations.
VMware Server running a Windows guest on a Linux host provides the user the advantages of both OSes. Namely, Linux stability and malware immunity, plus Windows program availability. It also provides future-proofing to the extent that this is possible on a modern computer system. As Linux programs become available that provide identical or better functionality, the user can easily move on to those Linux programs.
I use this setup myself, and I find myself increasingly using Linux applications that work just as well or better than Windows programs. Also, for the most part, Linux programs are free and can be installed from an installer GUI or a simple CLI command. By and large, once successfully set up, it just works.References for VMware Server Installation and Operation Documentation
You can download documentation for VMware Server at the links below. This documentation will provide you with the information referenced in this Recipe. It will also provide background, supplemental information that can help you troubleshoot problems and extend the functionality of VMware Server.
The following manuals can be found on this VMware Technical Documents References page. I recommend you grab these three:
Guest OS Installation Guide: This is for OS-specific information, including information on Vista, and 64 bit driver issues.
Virtual Machine Guide: This provides details on the virtual machines which are created by VMware Server in which the guest operating systems run.
VMware Server Administration Guide: This provides detail on how the overall VMware Server environment operates.
A. Lizard is an Internet consultant in the San Francisco Bay area. He has been writing for technology magazines and Web sites since 1987.
You May Also Like