Setting up your Virtual Machine - Computer Science

Setting up your Virtual Machine
Using VMware Player
CS-502 (Operating Systems)
Fall 2007
Hugh C. Lauer
Adjunct Professor
Worcester Polytechnic Institute
For this course, each student will need a virtual machine on which he/she can build, modify,
and test Linux kernels. We will be using OpenSUSE Linux version 10.2, a widely available
version of Linux that is freely distributable with source code.
Project assignments will require you to learn how to build a new version of a kernel, to add a
new service call to the kernel, and to create a message system to transmit messages among
Linux processes using the facilities of the kernel.
This document describes how to set up your virtual machine on your PC using the free
VMware Player program. You should have a modern PC with at least 8 gigabytes of free disk
space and (preferably) one gigabyte of RAM.
If you don’t have access to an adequate PC, other options are available for this course:–

You may use VMware Server, a virtual machine service application running on the
csopt4 server machine in the Computer Science department. Instructions for this
option can be found here: – (.doc, .html).

If you have a Macintosh computer with a Pentium processor capable of running
Macintosh Parallels, please see the instructor for help in setting up your virtual machine on that system. (One student was successful in this mode last fall.)
Virtual Machines
A virtual machine is an application program capable of simulating a computer with enough
fidelity and performance to mimic an actual hardware system. It simulates the microprocessors, memory, disks, network connections, CD drives, and many other devices. The virtual
machine concept originated in the 1960s, and it has now matured to the point that virtual
machines are used in a wide variety of commercial and operational settings.
Two terms are used in virtual machine technology:–


The host system is the hardware and operating system on which the virtual machine
application runs — e.g., your PC running Windows or the departmental server running Linux.

The guest system is the simulated machine, which runs a different operating system
and set of applications — e.g., Linux running on VMware on your Windows PC.
Copyright 2007, Hugh C. Lauer. All rights reserved. Permission is given for use in courses at Worcester
Polytechnic Institute, Worcester, Massachusetts.
1
The virtual machine application uses the host processor to simulate the guest processor, and
it uses files on the host system to simulate disks on the guest system. It also simulates other
hardware in the guest system, sometimes by using host hardware directly. For example, the
virtual machines distributed for this course allow you to access your CD or DVD drive and
your USB Flash Drive directly from your guest operating system on your PC.
A goal of this Operating System course is to provide experience in working directly with the
inner layers of a real operating system of the kind used by many people for their daily work,
including the WPI community. You will be exposed both to the breadth and depth of such
an operating system and also to many of its gory details. In order to do this, a safe place
must be provided for you to work — a place where you can make mistakes, crash your operating system, corrupt disks and data structures, etc., without harming anyone else and even
without harming your own, working PC.
The virtual machine provides this kind of environment.1 For this course, we are providing a
dual processor, dual disk virtual machine with OpenSUSE Linux version 10.2 already installed. The reason for two processors is to expose you to the issues of concurrent execution
at the kernel level of the operating system. The reason for two virtual disks is to minimize
the chances of losing your work after a crash. The primary disk is the system disk; this contains everything except the /home directory. If it becomes corrupted, you can safely replace
it with a new copy. The other disk contains just the /home directory; this is where you will
work, build new copies of the kernel, etc. If your virtual machine needs to be replaced, you
can still connect your previous home drive to the new one.
The virtual machine comes in two flavors — i386, the name given to Intel and compatible
32-bit architectures, and x86_64, the name given to Intel and AMD 64-bit architectures. Almost all students will be able to use the i386 version. The x86_64 version was created primarily for use on the CS Department server csopt4 but may be useful on other hosts.
Installing VMware Player
VMware is a company that makes and sells virtualization systems for commercial and scientific applications. VMware Player is a freeware package from VMware that designed to run
virtual machines that were created under some other VMware system. It does not have all of
the capabilities of other virtual machine systems — particularly the ability to take snapshots
and roll back to them. However, it is free, and it is adequate for the purposes of this course.
VMware Server is another free product of VMware that lets you create your own virtual machines. Many CS students keep a copy of VMware Server on their own PCs or laptops. It has
the ability to take and store a single snapshot, but it lacks some other useful virtualization
features, such as shared folders with the host operating system. (It does, however, run virtual
machines created on other VMware systems.)
The virtual machines for this course were created by the instructor and will be distributed to
students on DVD. There are three parts to setting up these virtual machines using VMware
Player: –
1
For many years, the undergraduate Operating Systems course at WPI had a different environment called
the Fossil Lab. This is a laboratory with dedicated hardware on its own network but isolated from the campus network. See http://fossil.wpi.edu. However, the Fossil Lab requires a student to be physically present
on campus, something that is impractical for graduate students who also hold full time jobs.
2

Obtain and install a copy of VMware Player.

Extract the contents of the DVD to an appropriate directory.

Boot up your virtual machine in VMware Player and make some adjustments for networking and for user identities.
Installing VMware Player
Download and install the VMware Player application program to the machine on which you
will work. When you download, be sure to select version 2.0 or later. The VMware Player application can be downloaded from here:–
http://www.vmware.com/download/player/
Versions are available for both Windows and Linux desktop environments, but there is no
version for the Macintosh. However, a VMware program called Fusion for the Macintosh can
be found at
http://www.vmware.com/download/fusion/.
You can get a 30-day free evaluation license, but after that you have to purchase it.
If you want to use the free VMware Server, you can download it from here:–
http://www.vmware.com/products/server/
You are on your own with respect to installing and using VMware Server or VMware Fusion.
Back to VMware Player, install the downloaded application as you would any other application. There seems to be nothing special about it. However, the installation package suggests
at one point that “Autoplay” be disabled for CD-ROM drives. I did not disable it, but this
might lead to confusion if certain CDs are inserted into a CD-ROM drive while the player is
running.
Expanding the CS-502 Virtual Machines
The DVD distributed in class contains two zip files plus a copy of this document. The zip
file are:–

CS-502_Fall_07-x86_64.zip, and
 CS-502_Fall_07-i386.zip.
These represent the two versions of the distribution. Expand the one you want, and you will
get a folder with the same name as the zip file If you open this folder, you get something
that looks like:–
3
The file Home (together with Home-s001, if it exists) is the virtual disk representation for
the /home directory. Protect and take care of these files, even to the extent of backing them
up. This is where you will do your work. (Note that during the course of building a full
Linux kernel, the home disk will grow to about 800 megabytes, and other actions may cause
it to grow larger.)
The VMware Configuration File named SUSE Linux or SUSE Linux 64-bit is a text file
describing your virtual machine. You may peruse it if you wish, but there is no need to edit
it. To start a virtual machine, you need to browse to (or double click on) its VMware Configuration File. The rest of the files are for implementing the virtual machine itself.
Before you can run the virtual machine, you need to decide whether you want Bridged networking or NAT networking (i.e., Network Address Translation).

If you have a home network that freely accepts new connections, choose Bridged.
This causes VMware to forward all network connections directly to and from your
network, making your virtual machine look like a piece of real hardware to the rest of
the machines on your network. Your virtual machine acquires an IP address via
DHCP, just like other machines on your home network. Any other system on the
network can therefore speak to the guest system directly.

On the other hand, if you are connected to a closely managed network such as the
WPI wireless network on campus, your virtual machine’s MAC address won’t be
recognized and therefore the network will deny you permission to connect. In this
case, choose NAT. This causes a module inside of VMware to translate the IP address of every packet so that it looks to the outside world as if it were coming from
4
the host system, not the guest system. The host system then translates the IP addresses of the replies to look like they were intended for the guest system.
The networking choice is specified in the Ethernet pulldown menu in the center of the title
bar of VMware Player after you start your virtual machine, as shown below and described in
the next section.
Starting your Virtual Machine for the first time
Start VMware Player, browse to and open the folder where you extracted your files, select the
VMware Configuration File, and click open. You may also simply double-click on a VMware
Configuration File to invoke the VMware Player with that file. This boots the virtual machine.
There are two things you need to do before you are ready to use it. These are

To fix the network configuration; and

To create a user identity for yourself.
The first thing that should appear is a dialog box like the one below:–
5
In this dialog, VMware is telling you that it wants to change the hardware address of the virtual Ethernet device of the guest virtual machine (i.e., its MAC address). The MAC address
of a VMware virtual machine is derived from a unique identifier, which in turn is derived
from the path name of the directory in which its configuration file resides. This new MAC
address is intended to keep the new virtual machine from being confused with the original
one distributed to you and with other machines (virtual or real) on the network. By selecting
the Create radio button and click OK, VMware Player generates the new unique ID and an
MAC address and writes it into the VMware Configuration File.
After you click OK, the virtual machine boots up, eventually producing a screen that resembles the one on the previous page. If you do nothing at this point, the virtual machine will
boot the default option (openSUSE 10.2). The numbers after the operating system identification are the version of the kernel. In the future, you will need to control the boot options; do this by clicking in boot screen, then using the arrow keys to select the desired option, and finally pressing Enter.
Note: You transfer the input focus of the mouse and keyboard to the virtual machine by
clicking in its window. You can return the input focus to the desktop by typing
CTRL-ALT. If the input focus is in the wrong place, the virtual machine won’t hear
you type or move the mouse.
Once the focus is in the virtual machine, you may use the up and down arrows to
select the booting option and Enter to invoke that booting option. There is a settable boot timer that controls how long SUSE Linux waits before booting the default
option. You may set the networking choice at this time.
During booting, the screen will briefly change to a text console, and then it will eventually
change to a graphical login interface.
Logging in
Your login ID is as student, and your password is CS-502. You will be presented with a
graphic desktop called KDE, the Linux Desktop Environment, shown below. This is the
6
SUSE Linux equivalent of the Windows desktop, and it is used much the same way. In particular, note the little green “Gecko” icon in the lower left corner. This is functionally
equivalent to the “Start” button in Windows. Click it to get a menu of program items and
other commands.
Note: In modern versions of Linux, you rarely have to log in as root. Most of the time,
you should log in as a non-privileged user and use the sudo command to invoke
root privileges where needed. This avoids accidents that are typical in most system
development environments. As a helpful reminder, KDE configures the user root
with a red desktop background that contains warning signs and images of bombs.
Updating the networking configuration
You next need to update Linux to recognize the new network address you just created in the
dialog box above. Although it is possible to do this by editing a text file, that is tedious, time
consuming, and error prone. A better way is as follows:–
Click the “Gecko” icon and select the third tab of this menu, labeled Computer. When the
tab opens, you will see at the top an item entitled Administrator Settings and in
smaller print below it YaST. Click this item to start the YaST program, SUSE Linux’s general purpose administrative setting tool. You will use YaST a lot; it is much easier than learning and remembering a book full of arcane shell commands.
When you start YaST, it asks you to enter the root password. This is CS-502, the same as
the password for the user student. You should next see a window resembling the following:–
7
Select the fourth item on the left, namely Network Devices. This expands the right
window to show several types of network devices. Click on the Network Card icon to
bring up the Network Setup Method window. Choose the “traditional method” and
click Next. This brings up the following window:–
8
Select the network device that says “Not configured” and click Edit. A set of default options will be presented in a dialog box. Accept these and click Next to return to the Network Card Configuration Overview window again. Finally, click Finish. This
causes SUSE to reconfigure its networking subsystem and start the network connection.
A convenient way to test the network connection is to open a terminal window (click the
Gecko icon in the lower left and select Terminal Window from the menu). This opens a
traditional Linux/Unix shell. Type the command
% sudo /sbin/ip address
This will list the IP addresses of the local connection (128.0.0.1) and of the newly configured
network card. You can also test the connection by invoking the Mozilla web browser in your
guest operating system or by trying to ping a known network address.
Creating a user identity for yourself
It is helpful to create a user identity for yourself and to get rid of the student identity that
comes with the distribution version of these virtual machines. To do this, go to the YaST
main window and select Security and Users in the left panel. Click on User Management in the right window and follow your instincts to add your own identity as a user. (We
suggest that you use your WPI e-mail identity.) Log out, and then log in with this new identity, and finally delete the student identity.
Useful Features
Shared Folders
Installed in your guest operating system are the VMware Tools. This is a set of drivers that
improve the performance and operation of the guest operating system in the virtual environment by setting up some private channels between the host and the guest systems. The
most useful feature is the shared folder between the host and the guest operating system. This
is a folder that lives in both the host and the guest operating system. You can move files into
it from one system and take them out from the other.
Shared folders are supported in VMware Player and VMware Workstation, but not in VMware
Server.
On the guest side, the shared folder is mounted in the directory /mnt/hgfs. On the host
side, it must be enabled and configured in VMware Player. The configuration dialog is accessed from the VMware Player menu as shown below. You will need to “enable” sharing and
specify which host folder you want to share.
9
VMware Tools
The VMware tools installed in your guest operating system have a tendency to disable themselves when you modify the kernel, even when you reboot back with the original kernel.
Among other things, this causes the shared folder facility to stop working. It also sometimes
causes the network card to stop working, and you have to go through the process of configuring it again, as you did above after the MAC address changed.
There are two ways to re-establish the VMware Tools:–

Execute the shell command
sudo /usr/bin/vmware-tools-config.pl
This uninstalls and then reinstalls the VMware Tools. As part of the installation step, it
recompiles the VMware Tools with the header files of the current operating system
kernel. If it cannot find these header files, it will ask you for a pathname. Rebuilding
VMware Tools takes only a few minutes.

Reboot with the last known kernel for which VMware Tools worked. Execute the following two shell commands:–
sudo rm /etc/vmware-tools/not_configured
sudo /etc/init.d/vmware-tools start
10
The first command removes the file /etc/vmware-tools/not_configured,
which was put there by VMware Tools when it tried to start up with a kernel that did
not match the one it was compiled with. Once this file is in place, VMware Tools will
not even attempt to start up.
The second command restarts VMware Tools. Presumably, if the kernel is right, it will
start operating again. In particular, the shared folder will become accessible.
Disaster Recovery
In the unlikely even that your virtual machine becomes so badly corrupted that you cannot
use it, do the following:–

Unzip the appropriate zip file from the distribution DVD to a new folder

Open the folder of the old (unusable) virtual machine

Copy file Home (and Home-s001, if it exists) from the old virtual machine folder to
the new one. This will replace the corresponding files in the new virtual machine
folder. Do not copy the folder Home.vmdk.lck or any other file or folder with the
.lck extension.

Boot and initialize the new virtual machine as described in this document.
You should now have a brand new virtual machine, but with the /home drive taken from
your old one. Your work on the Linux kernel should be intact.
Conclusion
That’s it. Enjoy your virtual machine. You are now ready for your first kernel project. When
you are ready to take a break, you may power off your virtual machine by invoking the
“leave” tab from the Gecko menu and selecting the appropriate option. You may also “Suspend” the virtual machine by simply exiting VMware Player. When you open VMware Player
again and select your virtual machine in the dialog box, it resumes where you left off.
Documentation
Documentation for VMware Player can be found here:–
http://www.vmware.com/support/pubs/player_pubs.html
There is a lot of documentation about other VMware systems here:–
http://www.vmware.com/support/pubs/
Documentation about OpenSUSE Linux can also be found on-line at
http://www.novell.com/documentation/opensuse102/
This includes a getting started guide, a user’s manual, and administrator’s manual, and other
information. Do not try to print these. Together, they are over 1000 pages.
11