CSE 451: Operating Systems, Winter 2004
  CSE Home   About Us   Search   Contact Info 
 
Course Home
 Home
 
Administrivia
 Overview
 Using course email
 Email archive
 
Materials
 Lectures and readings
 Sections and tutorials
 Midterm and final
 
Assignments
 Homework
 Projects
 
Lab information
 Lab information
 Linux information
   

Getting comfortable with the projects

Some of the projects for this course will involve diving into the Linux OS kernel source code and making some small modifications. There are two things that you need to be familiar with before you can effectively do these projects: the configuration of the lab machines that we have set up for you, and the process by which you compile, install, and test a new kernel that contains your modifications. This page describes these two things in detail. All questions should go to the course TA's, or if they are generally applicable to the class, to the course mailing list.

[ Project lab setup | Compiling your first kernel ]


The Project Labs

For this quarter, you'll be working on your projects in CSE 006. In this lab, the WinXP machines have been configured with the software necessary for this course (VMware). There are also two dedicated linux machines for this course: spinlock.cs.washington.edu and coredump.cs.washington.edu.

Each of you should already have an account created on spinlock and coredump.

Roughly speaking, each project will involve the following phases:

  1. Read through the Linux source code: Before you can modify the code to satisfy the project, you need to understand the code that you will modify. You will use your account on spinlock or coredump for this purpose: each of you will make a private copy of the kernel source tree in specially created directories on these machines (described below); you can then safely navigate through the source tree without fear that somebody else has changed it.

  2. Edit the Linux source code, and compile a new kernel: Once you think you know what to do in order to do a project assignment, you need make your changes to the Linux source code (either by editing existing files, or by creating new files, or both). You will then compile a new kernel. Again, you will use spinlock or coredump for this; each of you will edit your private copy of the kernel source tree, and then compile the new kernel (using spinlock or coredump) from your modified private source tree.

  3. Test/benchmark your new kernel: Once you've successfully compiled a new kernel image, you will then need to try it out. Instead of having dedicated physical machines for experimental kernels, we've installed VMware on the WinXP machines in CSE 006. VMware is a virtual machine monitor: it is a software layer that perfectly emulates the x86 architecture, thereby allowing you to install and use any x86-based operating system on top of it. In other words, you can launch the VMware program on these WinXP machines, and then boot into Linux from inside VMware. So, once you've compiled a kernel image (which is simply an executable file), you will transfer the kernel image to one of these WinXP machines, and from there, using a process we describe below, you'll copy the image into VMware and boot into your new kernel.
As 451 students, you have priority access to the lab machines with VMware installed. However, if you look at the three phases above, you'll realize that you only need to use these machines during the third phase. I expect that you'll spend most of your time on phase 1 and phase 2. Please do not exercise your priority to get onto these machines if you're just working on phase 1 or 2; save that power for phase 3, otherwise you'll needlessly cause friction with other students.

spinlock and coredump

To remotely log into spinlock or coredump, you need to use ssh. On the lab WinXP machines, you can find ssh as:
Start->Programs->Internet and Remote Connections->SSH->Secure Shell Client
If you start an Xwindows server before you run ssh, then you'll be able to run Xwindows clients on spinlock or coredump. (For example, you'll be able to launch the Xemacs client.) To start an Xwindows server, run:
Start->Programs->Internet and Remote Connections->Reflection->Reflection X
Your home directory on these machines is your usual /homes/iws/ directory, and it is backed up. However, due to the usual disk space quotas, you will not have enough quota in your home directory to copy or compile a kernel. Instead, we have provided each of you with local disk space. Your local disk space is in /cse451/username, where username is your unix account name. So, when you make your copy of the linux kernel and when you edit or compile it, you should do so in this local directory, not your home account.

However, these local directories are not backed up. This means that if the disk crashes on either of these machines, all of the files in your local directory will be blown away. Thus, I strongly recommend that you keep copies of critical files in your home account; in particular, I'd keep a copy of every file that you've edited or created, and copies of the kernel images that you create (Don't copy the entire kernel source tree, though: only copy changed files).

One more detail: your local directory on spinlock or coredump can be accessed from the WinXP machines using a file transfer client. On the lab WinXP machines, you can find a file transfer client at:

Start->Programs->Internet and Remote Connections->SSH->Secure File Transfer Client
This is how you will copy a kernel image from your local directory on the Linux servers to the particular WinXP machine that you're using.

VMware

To launch VMware, simply run:
Start->All Programs->VMware->VMware Workstation

If a dialog box pops up, select "Open Existing Virtual Machine". If Linux is on the list, double click it, otherwise hit OK to browse, and then select c:\Program Files\VMWare\vms\linux\Linux.vmx.

If no dialog box pops up, click on "Open Existing Virtual Machine" in the VMWare window. Browse to and select c:\Program Files\VMWare\vms\linux\Linux.vmx.

By selecting this, VMware will boot into a version of Linux that has been carefully prepared for use with the 451 course. In particular, this configuration has the following properties:

  1. The hard drive has been set to be non-persistent; if you power down the virtual machine, and power it back on (or if you quit and restart VMware), then any changes you made to the file system inside VMware/linux will be lost. This is a good thing: it means every time you boot VMware/linux, it will boot into a well-known, sane configuration, with a working kernel. However, this means that when you install your new kernel, you can't power down the virtual machine; instead, you'll software reboot it from inside linux (as described below).

  2. VMware/linux has been configured for host-only networking; this means that VMware/linux can only communicate with the WinXP host that is running it, rather than the Internet at large. Similarly, the only way to get files into VMware/linux is to ftp them from the WinXP host on which you're running VMware/linux. This was done for security reasons.

  3. There is only one user account: user name root, and password rootpassword. Note that I am fearlessly advertising this account name and password on a world readable web site. The reason I'm not afraid to do this is because of properties 1 and 2 above. Because of 2, only people actually sitting at the WinXP machine can log into VMware/linux, and because of 1, nothing you do can mess it up for other people.
We have one very strictly enforced rule for VMware usage: don't mess with the VMware configuration itself. If you do, we'll be extremely upset with you, since you might inadvertantly cause trouble for other people.

Now select Linux and then press the Power On button to boot Linux inside VMware. VMWare may prompt you with an error message regarding a CPUID bit. This message can be safely ignored. You will then see the boot sequence as Linux loads itself, initializes devices, etc., and once this has finished, you'll be asked to log in. Do so as username root, and password rootpassword .

To copy files into VMware/linux, you need to use ftp from the WinXP host running VMware. So, bring up your favorite FTP client, and connect to the host 192.168.93.2. This is the IP address of the Linux system running inside VMware (this IP address is the same irrespective of which WinXP machine you're using, thanks to the magic of host-only networking).


Compiling and running your first kernel

Goals

  • To familiarize yourself with the class work environment.
  • To learn how to build the Linux kernel.
  • To learn how to test kernels under VMware.

Setup

This document provides you with step-by-step instructions for building and testing a kernel. For further information on building kernels, refer to the Linux Kernel HOWTO. The VMware web site (http://www.vmware.com/) has further information on VMware.

The Process

Part 1: Build a kernel image

Log onto spinlock or coredump. You should all have accounts on the machines. SSH is available as

Start->Programs->Internet and Remote Connections->SSH->Secure Shell Client
on the WinXP machines.

Change directory to /cse451/username. You will be using this directory for your kernel development. Copy /cse451/projects/linux-2.4.20.tar.bz2 into this directory. This archive contains the kernel source code. Open it with the command "tar xvjf linux-2.4.20.tar.bz2 ".

Change directory to linux-2.4.20. Compile the kernel with "make dep", then "make bzImage". (Note that it is not necessary to run "make configure " or similar options). Compiling will take a long time (i.e. 10 minutes or so) the first time you do it, but you won't be recompiling every file all the time, so it will go much faster later on.

Assuming compilation is successful, your new kernel image will created, and named ./arch/i386/boot/bzImage.

Part 2: Transfer image to VMware

Copy the new kernel image from arch/i386/boot/bzImage to the WinXP machine you will be using for testing.

To do this, your local directory on spinlock or coredump can be accessed from the WinXP machines using a file transfer client. On the lab WinXP machines, you can find a file transfer client at:

Start->Programs->Internet and Remote Connections->SSH->Secure File Transfer Client

Launch VMware with Start->All Programs->VMware->VMware Workstation .

Select "Open Existing Virtual Machine". If Linux is on the list, double click it, otherwise browse to it at

C:\Program Files\VMWare\vms\linux\Linux.vmx

Power on the virtual machine.

Login as "root", password "rootpassword ". (To get the mouse back out of VMware, you need to hit Ctrl-Alt-Escape.)

From Windows, ftp the kernel image to 192.168.93.2. This is the IP address of the Linux system running on the virtual machine, irrespective of which WinXP machine you are using. To do this, open Internet Explorer and go to the URL, ftp://root:rootpassword@192.168.93.2  and then copy your kernel image into this directory.

Part 3: Test the kernel

The kernel image you just ftp'd should be under /root/ on VMware/Linux. Copy it to /boot/bzImage-test.

The Linux boot loader is called lilo. At boot time, lilo selects an operating system image to run. You need to instruct lilo to select your image in order to test it.

Edit /etc/lilo.conf to append the lines in this . You might want to type this up in vi or emacs rather than copying, because of newline/linefeed problems. Note that the leading space in the second and subsequent lines are tabs.

Next, from Linux, run /sbin/lilo ; this will install your new kernel, and tweak the boot sector of the disk to load into it.

Finally, reboot the virtual machine by issuing the command shutdown -r now (from the shell). When the machine reboots, you will see a LILO boot: prompt; once you see this, type test in order to boot into your new kernel image. (Note that you need to click on contents of the vmware window with the mouse in order to have keyboard input fed to vmware/linux.)

Part 4: Some helpful hints
  • Kernel Debugging: The standard kernel source is configured to support IKD, the interactive kernel debugger. See the documentation in the Documentation/kdb directory of the kernel sources.

  • Adding new files to the kernel source tree: If you need to add a new file to the Linux source tree, do it in the following manner:
    • Determine which existing directory the file(s) will live in
    • Edit the Makefile in that directory, and add the name(s) of the .or file(s) that will be created to the definition of O_OBJS.

  • To build the kernel, you must be in the top-level source directory (the one containing the file named REPORTING-BUGS).