Getting comfortable with the projects

The projects for this course will, for the most part, 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 three software labs, Sieg 231, 232, and 329. In these labs, there are a total of 28 Win2K machines that have been configured with the software necessary for this course (VMware). These are the Dell Precision P4 machines, identifiable by their black cases. There are also two dedicated linux workstations for this course: spinlock.cs.washington.edu and coredump.cs.washington.edu.

Each of you should already have an account created on the two machines.

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. This quarter, instead of having dedicated physical machines for experimental kernels, we've installed VMware on 28 Win2K machines in Sieg 231, 232, and 329. 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 Win2K 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 Win2K 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; all of these machines have signs on them attesting to this. 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 classes' students in these labs.

spinlock and coredump

To remotely log into spinlock or coredump, you need to use ssh. On the lab Win2K machines, you can find ssh as:
Start->Programs->Desktop->Tools->Tera Term->SSH Telnet
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 X emacs client, or netscape.) To start an Xwindows server, run:
Start->Programs->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 Win2K machines using Samba. To do this, simply bring up an IE window, and type an URL like:

\\spinlock.cs.washington.edu\cse451\johnny
Or:
\\coredump.cs.washington.edu\cse451\johnny
Replacing "Johnny" with your Unix user name. This is how you will copy a kernel image from your local directory on the Linux servers to the particular Win2K machine that you're using, when you're ready to install the kernel image in VMware/linux.

VMware

To launch VMware, simply run:
Start->Programs->VMware->VMware
When the dialog box pops up, select "Open an existing configuration". If Linux is on the list, double click it, otherwise hit OK to browse, and then select c:\Program Files\VMWare\vms\linux\linux. 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 Win2K 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 Win2K 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 Win2K machine can log into VMware/linux (and, in fact, only people enrolled in this course can run VMware), 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.

Once VMware starts up, and after you've selected Linux_2 in the initial dialog box, 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. i 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 Win2K host running VMware. So, bring up your favorite FTP client, and connect to the host 192.168.93.2. 192.168.93.2 is the IP address of the Linux system running inside VMware (this IP address is the same irrespective of which Win2K machine you're using, thanks to the magic of host-only networking).

 


Compiling and running your first kernel

 

Goals

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 (find it at http://www.kernel.org/). 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 now. SSH is available as

Start->Programs->Desktop Tools->Tera Term->SSH Telnet
on the Windows machines.

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

Compile a kernel with "make dep", then "make bzImage". (Don't forget to read the Kernel HOWTO, available online at http://www.linux.com/howto/Kernel-HOWTO.html.) (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 Win2K machine you will be using for testing. Make sure it is one of the machines that has VMware installed.

To do this, mount your work directory on spinlock or coredump as a remote drive under Windows. Open a Windows Explorer and select Tools->Map Network Drive..., then choose a drive letter and use file:\\spinlock.cs.washington.edu\cse451\username for the folder name.

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

Select "Open an existing configuration". If Linux_2 is on the list, double click it, otherwise hit OK to browse. Select c:\Program Files\VMWare\vms\linux\linux.

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 Win2K machine you are using. Again, use root/rootpassword.

You could also start the ftp transfer under Linux on VMware, but then you'd have to figure out the IP address of the Win2K box. For security reasons, networking under VMware is limited to the host (Win2K) machine.

Part 3: Test the kernel

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

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: prompt; once you see this, hit Tab to bring up a boot: prompt, then 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