This is currently an incomplete work in progress!! Please expect it to change

Linux
CS 423: Operating Systems Design
          

Guide to Testing a Kernel

EWS Disk Space Quotas

Each student on EWS is allocated 3Gb of disk space for their overall work. Unfortunately, in this course you will need a fair piece of that. Please take some time at the start of this semester to clean up your directory to avoid difficult situations later on.

If you should ever find yourself having exceeded your quote, you may have trouble even removing files. In this case, you should try executing:

cat /dev/null > <some_big_file>

If all else fails, you might try moving a file temporarily to /scratch, which is local storage on the server itself. This is a shared resource, so you must make sure to monitor this disk usage carefully, and be sure to remove any files afterwards.

Using the QEMU Environment

This semester, we are using the QEMU machine emulator. One advantage of QEMU is its ability to run a linux kernel image that was compiled outside the Virtual Machine. We will be compiling the kernel directly on the EWS machines, instead of inside a virtual machine running in qemu (running on an EWS machine). This will save us a fair bit of time. However, the price we pay for this will be more complicated start-up procedure, as you will see below. QEMU has been installed on the EWS Linux machines for us to use. When running qemu, or any of the related programs, please run it from a window that is dedicated to that, that you would not mind killing, and do not run qemu in the background. If something goes wrong you want to be able to kill qemu and killing the window that spawned it will do this (particularly if it is not running in the background). To start up qemu with a small linux kernel (version 2.6.20), execute

qemu-system-x86_64 -hda ~cs423/disk_images/linux-0.2.img -no-reboot -curses

If you are running X11 and and connected with the -X or -Y flag, and you are not using a Mac, you may be able to leave off the -curses and have qemu run in a separate window. If you are running on a Mac, you might want a liitl extra protection form system lockup given by running xterm -font 10x20 from within the xterm you used to ssh to remlnx.ews.illinois.edu. The -hda option specifies a disk image from which to boot. The -no-kqemu option specifies not to use kqemu, which has not been installed on the EWS machines. The -no-reboot option specifies not to automatically reboot the VM when we exit.

If this much is working, you should find yourself in a shell. You can do some basic things like ls and cd.

Creating a COW Disk Image

At this point, you need to have a disk image of you own to modify and use. There is a base Ubuntu image (without a bootloader) found in the same disk_images directory as linux-0.2.img. However, this image exceeds 3G in size, and would likely blow away your quota if you were to try to copy it. Still, this is the base from which you will need to work for testing the kernels you will build in some of the mps. The solution for htis is to make a COW (copy-on-write) disk image as follows:

qemu-img create -b ~cs423/disk_images/ubuntu_noboot.img -f qcow2 <your_mp_dir>/mp1.img

The base image ubuntu_noboot.img does not have a bootloder installed. Therefore, it can't be used in quite the same way as linux-0.2.img above. Instead we will boot using an additional -kernel option that allows us to supply externally a kernal from which to boot.

Cofiguring the Kernel

We will be using Linux kernel version 2.6.37.0 this semester. You should begin by creating a directory <your_src_dir> into which you will put the source for the linux kernel. Having created that, next you need to populate it. We have put a bz2 compressed copy of the source for linux-2.6.37.0 on the ews machines. To use it to populate <your_src_dir>, execute the following:

tar -xjf ~cs423/semesters/curSemester/resources/linux-2.6.37.tar.bz2 -C <your_src_dir>

The next step is to configure your your kernel. Change into <your_src_dir> and run

make menucofig


To enable networking, in the menu that comes up, go to

Device Drivers --> Network device support --> Ethernet (10 or 100Mbit)

and change "PCI NE2000 and clones support" to be compiled into the kernel (as opposed to being a module). The network driver will be crucial for us to install all the other modules. Exit and save. If you do n;t wish to include networking at this time, you may just exit and save without making any changes.

Compiling a Kernel Image

Once you have finished configuring the kernel, you can compile the kernel by executing (in the same directory) the following:

make -j16 bzImage

This will create a file <your_src_dir>/arch/x86_64/boot/bzImage

Booting QEMU with an External Kernel

Once you have created a custom kernel, you may start up qemu with this kernel by executing

qemu-system-x86_64 -hda <your_mp_dir>/mp1.img -kernel <your_src_dir>/arch/x86_64/boot/bzImage -append "root=/dev/hda1" -m 1024 -no-reboot -curses -net nic,model="ne2k_pci" -net user

This will boot the custom kernel image, with root filesystem /dev/hda1 and 1024M (1G) of RAM. The boot should be successful, however you will see error messages on boot, such as

modprobe: FATAL: could not load /lib/modules/2.6.28.37/modules.dep: No such file or directory


This is because although we are booting the custom kernel image, we do not have the modules installed.

To check out that all is working, you may log in to the machine as cs423 with password cs423. To confirm that you are running the kernel you just compiled, run

uname -a

You should see 2.6.37.0. Or get more detailed information using dmesg. One of the first few lines should have output similar to

Linux version 2.6.37 (egunter@linux2.ews.illinois.edu) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Mon Jan 24 21:45:40 CST 2001 To exit qemu you may execute

sudo halt -p

and give cs423 as the password when requested.
Last modified: Thu Jan 27 22:37:42 CST 2011