Like most programmers, I have my favorite development environment. For me, it’s Linux. I'm uncomfortable if I'm not working in Emacs, writing shells scripts and hacking makefiles. That doesn't mean I can survive on Red Hat alone. There are many reasons to run other environments—other versions of Linux, for example, and Windows, too. In this article, I’ll show you how by running VMware for Linux, I can transform my dual-boot system into something much more.
E-mail has grown out of its ASCII childhood. I often receive HTML mail. Microsoft Word and Excel documents arrive as attachments. I even receive voice mail via e-mail. The easiest way for me to deal with these Windows-based documents is to use Microsoft Outlook Express to read my mail and interoperate with Microsoft Office applications.
So how do I do that? The classic approach is dual booting, with different operating systems on separate partitions. We all know how much fun that is. You have to shut down Linux. Reboot the machine. Come back up in Windows. Do your Windows chores. Repeat the process to get back to Linux. And let's not even talk about the complications of getting a file attachment or a bit of text from the Windows side back to Linux. So I skip dual booting for these everyday chores. I can handle my complex e-mail in Windows and have my development environment, too, by running Windows NT in a virtual machine.
By running VMware for Linux, I can move between my Linux development environment and my Windows personal environment simply by moving my mouse in and out of a window. VMware lets you interact with its virtual machines in two different ways. In Window mode, the guest environments appear in their own windows. As the mouse moves into and out of a window, you are transferred from one operating system to another. Cut and paste (for ASCII text) works just as it does between any other two windows. And you can share files across a network between host and guest or between guests, just as if they were separate physical computers. (This even works if you're not actually connected to a LAN. You can set up a virtual network that's completely self-contained on the host computer.)
In full-screen mode, the guest environment takes over the entire screen, making it almost impossible to tell that the guest is not the native operating system. Full-screen mode gives the guest the entire resolution of the display—very handy if you have several programs running in the guest environment or if you want to get a good look at a large document.
Setting it up
The simplest way to set up a VMware virtual machine is to use a virtual hard disk. The contents of the virtual disk are stored in a file on your host computer's file system. If you already have a dual-boot machine, however, you may not want to re-create either environment on a new virtual drive. Instead, think "raw disk." That's the term we use to refer to using an existing drive or partition on your computer inside a VMware virtual machine.
The steps you need to follow to convert an existing dual-boot system will vary, depending on which host and guest operating systems you want to use and whether you're working with an existing dual-boot installation. In this article, I'll take you through the steps for converting a dual-boot Windows NT and Linux machine to use Linux as the host operating system and the existing Windows NT installation as the guest.
For a complete rundown on other variations on this theme, check the support section of the VMware site .
Note that using an existing disk partition, or "raw disk," inside a virtual machine is an advanced feature of VMware. I wouldn't suggest setting up a raw disk the very first time you create a virtual machine. It's better to familiarize yourself with the basic setup steps first. You should, at minimum, create and configure a virtual machine with a virtual disk and install an operating system. In addition, booting a previously installed operating system within a virtual machine may not work on some existing installations. Your experience may vary depending on your hardware configuration and guest operating system installation. Also, be aware that some issues may arise because of special features of Windows 2000. I won't touch on those here, because I'm describing an NT setup. But if you’ve installed Windows 2000 on a computer with ACPI features and want to set up a VMware virtual machine running from a raw disk, be sure to review the instructions on the VMware Web site.
VMware supports using raw disk partitions only on IDE drives, so that's what I'll describe here. Booting guest operating systems on raw SCSI drives is experimental. Back to the mantra: Check the VMware Web site if you want to try using a SCSI raw disk. VMware uses description files to access each raw IDE device on the system. These description files contain access privilege information that controls a virtual machine's access to certain partitions on the disks. This mechanism is used to prevent users from accidentally trying to run the host operating system again as a guest or trying to run another guest operating system that the virtual machine was not configured for. The description file also prevents accidental writes to raw disk partitions from badly behaved operating systems or applications.
In the steps that follow, you’ll use the VMware Configuration Wizard to configure VMware to use an existing raw disk partition. The wizard will step you through creating a configuration for a new virtual machine, including configuring the raw disk description files. VMware can work with boot managers you might already have installed on your computer. The boot manager will run inside VMware and present you with a choice of guest operating systems to run. You have to select the guest operating system manually; be sure you choose the operating system that this configuration was intended to run. Okay, that's enough cautions for now. Let's get started.
You need to create a separate configuration for each guest operating system. Allow read/write access to the partitions used by that operating system only. First, you have to take steps to set up separate hardware profiles for your Windows NT setup—one that you'll use inside the virtual machine and one that you'll use when you boot NT natively on the computer. Why? Keep in mind that each virtual machine provides a platform that consists of the following set of virtual devices:
- · Virtual CD-ROM
- · Virtual IDE and SCSI hard disk drives
- · Standard PCI graphics adapter
- · Standard floppy disk drive
- · Intel 82371 PCI Bus Master IDE controller (includes primary and secondary IDE controllers)
- · BusLogic BT-958 compatible SCSI host adapter
- · Standard 101/102-key keyboard
- · PS/2-compatible mouse
- · AMD PCNET Family Ethernet adapter (PCI-ISA)
- · Serial ports (COM1-COM4)
- · Parallel ports (LPT1-LPT2)
- · Sound Blaster 16-compatible sound card
This set of virtual devices is different from the set of real hardware devices in your physical computer. If an operating system is installed directly into a VMware virtual machine, the operating system will properly detect all the virtual devices by scanning the hardware. However, if an operating system is already installed on the real machine (for example, in the dual-boot configuration I'm talking about here), the operating system will already be configured with the real hardware devices. So you’ll need to create separate hardware profiles to simplify the boot process. Each Windows NT hardware profile is associated with a set of known devices. If more than one hardware profile exists, you'll be prompted to choose between different hardware profiles at boot time. If you pick the wrong profile, any mismatches will lead to errors reported by the device drivers and the devices will be disabled.
Here's how to set up hardware profiles for your real and virtual machines:
- 1. Before running VMware to boot your existing Windows NT operating system, boot it natively and create two hardware profiles, which you can call Real Machine and Virtual Machine. To do this, open Control Panel and click the System icon, then select the Hardware Profiles tab. Click the Copy button and name the copies appropriately.
- 2. While still running natively, use the Device Manager to disable some devices from the Virtual Machine hardware profile. To do this, open Control Panel and click the Devices icon, then select the individual devices to disable. Things to disable in the Virtual Machine hardware profile include audio, MIDI and joystick devices, Ethernet, and other network devices and USB devices. Remember to disable them in the Virtual Machine hardware profile only.
- 3. Reboot the machine into Linux.
- 4. Check operating system partition mounts. (Be sure the existing raw disk partition(s) that you plan to configure the virtual machine to use are not mounted by Linux.)
- 5. Set the device group membership or device ownership. The master raw disk device(s) needs to be readable and writeable by the user who runs VMware. On most Linux distributions, the raw devices (such as /dev/hda, /dev/hdb) belong to group-id disk. If this is the case, you can add VMware users to the disk group. Another option is to change the owner of the device. Please think carefully about security in exploring different options here. It is typically a good idea to grant VMware users access to all /dev/hd[abcd] raw devices that contain operating systems or boot managers and then rely on VMware's raw disk configuration files to guard access. This helps provide boot managers with access to configuration and other files they may need to boot the operating systems. For example, LILO needs to read /boot on a Linux partition to boot a non-Linux operating system that may be on another drive.
- 6. Run the VMware Configuration Wizard.
- 7. In the Configuration Wizard:
- · Read the introductory text.
- · Click Next.
- · Check the box for the Windows NT operating system you have on raw disk. This is used to pick some simple defaults for VMware configuration settings and give default names to configuration files. Most of the default settings can be changed later with the Configuration Editor.
- · Click Next.
- · Specify the virtual machine directory. This is where the configuration files are placed. Leaving the default is often a good choice.
- · Click Next.
- · Choose Existing Partition from the virtual disk type settings.
- · Click Next.
- · Select the read/write option for the disk partition(s) that contain the guest operating system being configured.
- · Click Next.
- · Configure CD-ROM device settings as required.
- · Click Next.
- · Configure floppy device settings as required.
- · Click Next.
- · Configure networking settings as required.
- · Click Next.
- · Look through the confirmation page to see what’s about to be done. Click Back if you need to change settings. Note the location of the configuration file (.cfg). This is the file you’ll need to specify when you run VMware.
- · Click Done.
- 8. Start VMware and check the configuration. Type vmware and select Open An Existing Configuration. Browse to the .cfg file you just created and open it. Click Settings | Configuration Editor and check that your IDE configuration specifies at least one raw disk description file. These files are named <configuration-name>.hda, <configuration-name>.hdb, etc. Also modify any configuration options you want to change from the Configuration Wizard's defaults—for example, you may want to change the amount of memory allocated to the guest operating system. Note: It is possible to specify using a raw device directly in the VMware Configuration Editor. This is potentially hazardous and VMware does not support users doing this. Stick to the Configuration Wizard for the initial steps in setting up the virtual machine.
- 9. If you have multiple IDE drives configured on a system, the VMware BIOS will normally attempt to boot them in this sequence:
- · Primary Master
- · Primary Slave
- · Secondary Master
- · Secondary Slave
- 10. Power on the virtual machine. Press the Power On button. VMware should start, run the Phoenix BIOS, then boot from the master boot record (MBR). If you’re using a boot manager, choose the target operating system from the list of options it presents.
- 11. Remember: The virtual machine hardware environment that the guest operating system is about to run in for the first time probably differs significantly from the real hardware of your machine.
The next step
Keep in mind that if you have set up your virtual machine to use the raw disk as an undoable disk, you’ll need to either commit or discard the changes to the undoable disk before you reboot Windows NT natively. You'll find lots of detail on the VMware disk modes on the VMware Web site. But briefly, the reason you need to be sure to commit or discard changes before a native reboot is that when you're using a disk in undoable mode, changes you make during a virtual machine session are not actually written to the target disk. They're saved in a redo log file until you tell VMware to commit them—a choice that's offered to you when you shut down the virtual machine. Or you can choose to discard the log file. That will put you back where you were before you booted the virtual machine. If you don't commit or discard the changes before rebooting natively, the next time you start Windows NT, the actual files on the NT disk will be out of sync with the changes recorded in the redo log.
After the operating system has finished booting, view the event log to see which real devices have failed to start properly. You can disable them from the Virtual Hardware profile using the Device Manager. Confirm that your virtual devices are working properly, specifically the network adapter.
Install the VMware tools (by choosing Settings | VMware Tools Install). The VMware tools will appear and run in both hardware configurations but will have an effect only in the Virtual Machine hardware configuration. Note: The next time you reboot Windows natively using the Real Machine hardware profile, some virtual devices may appear in the device list. You can disable or remove these virtual devices from the Real Machine hardware profile in the same way that you removed real devices from the Virtual Machine hardware profile.
So there you are. You need to take some care during the setup, but it's not a painful process. And now you can get to the same Windows NT setup either in a virtual machine or by dual booting.
Scott Devine, cofounder and member of the technical staff at VMware, was a Ph.D. candidate in computer science at Stanford University prior to founding the company. Mr. Devine's primary research interests are in operating systems and computer architectures, and he was a key member on the SimOS and Disco virtual machine research teams. Mr. Devine holds a B.S. degree from Cornell University and an M.S. from Stanford University.The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.