An Introduction to the Linux-based Assignments

Note: Please use the class discussion board (you can find it on your blackboard) as a communication and Q&A tool.  Should you still need to send an e-mail inquiry, address it to the TAs and cc the instructor. 

A few words about QEMU and Linux

Linux is a Free Operating System kernel originally spear-headed by Linus Torvalds. It has been adopted by many UNIX-like Operating Systems distributors. GNU/Linux is a variant that is built around the Linux kernel and software (compiler, libraries, shell, etc.) by the GNU Project. Debian is a Free GNU/Linux distribution. We will be using Linux kernel 3.18.77 from the kernel repository. We will be using a stable Debian release (Etch) as the distribution with which we test our Linux kernel modifications.

QEMU (Q Emulator) is a processor emulator that began as a project by Fabrice Bellard. It is also Free software, can emulate many different CPUs, and it is stable and fast (QEMU relies on dynamic binary translation to achieve reasonable performance, but can also use a virtualizer to boost it even more). QEMU is a full system emulator so it can give you access to the network and emulate your peripheral devices; we will be providing you with a file, which is the virtual disk image where Debian is installed. We will be using QEMU to virtualize a whole Debian system with an i386 CPU.

The bundle of QEMU as the system emulator, Debian GNU/Linux as the system, and the latest Linux kernel will be our testbed for Linux kernel development. We will be referring to it as QDGL from now on (QEMU - Debian GNU/Linux). We will be referring to your desktop or whatever machine you run QDGL on, as the host OS, and the virtualized Debian GNU/Linux as the guest OS.
QDGL Disclaimer

The QDGL bundle is a bundle of Free software and is also available as such and without any guarantee.

You are not required to use QDGL; you can build your own configuration or use any other tool you want, but you will have to confirm your assignment works on QDGL. For the purpose of this class, QDGL has been pre-configured for your convinience, so it is suggested that, though you can build your own configuration, you stick to the one provided. Since this is the first time we will be using this platform, we might experience bugs occasionally; we will need your cooperation to fix them, so make sure you communicate the bugs and problems you might experience. More importantly, make sure you make backups of your work regularly.

QDGL: List of files you 'll need and how to acquire them

In the QEMU/Linux assignments, you are required to use QDGL to modify and test a Linux kernel. You will be using your personal cs/csug accounts for development.

First you need to copy QDGL to your directory. You will need ~562MB just to grab QDGL, and another ~400M as soon as you untar and compile the kernel, so make sure you have at least 1GB of free disk space in your account (the instructor and system administrators have made sure you have the appropriate allocation). We will be using a stock kernel from the kernel repository, version (pre-configured).

Below is the list of the contents of QDGL:

To acquire QDGL
*    Or anyone with access only to the undergrad network
** Or
anyone with access only to the grad network

QDGL: Test driving your system

To take a look at the default Debian installation, move into your copy of the QDGL directory (cd QDGL), and on your terminal run the following instruction:

./qemu/bin/qemu -m 64M -L ./qemu/share/qemu/ -hda hda.img -nographic


Alternatively, if you choose to use the SDL interface, you can simply neglect the last parameter (-nographic). If you have access to the X server of your Linux host, you should also be able to see a virtual monitor in a separate window (this option uses the SDL libraries, which you should already have installed) instead of the terminal.
This should boot Debian from the virtual disk, with the distribution kernel. You will be prompted by the boot loader to choose the kernel to boot (Press any key to continue) - you can safely just wait 5sec, which will start the default kernel, or you can pick it yourself in the grub menu.  After the kernel log messages, you will be prompted with the login ; the system is called cs2456. Below are the two accounts which already exist in the system

USER: root       PASS:***
USER: cs2456  PASS:***

The passwords to those accounts will be handed over in class. You should change your personal virtual machine passwords as soon as possible. You should not enter as root unless you absolutely need to.

Hitting the command uname -a you can check the system information -- you should see Debian's pre-installed kernel version (2.6.18-6).

You should always make sure you turn off your client properly ; the virtual disk is setup as a journaled ext3 filesystem, but properly shutting down is essential to keep it "clean". Another good habit would be to be taking backups of your virtual disk image at checkpoint events. To turn off your system safely, if logged in as root just type


otherwise, if logged in as cs2456, type

   sudo poweroff

QDGL : Compiling and testing a new kernel

For the following we are assuming that you are working on a GNU/Linux environment, such as cycle1.cs/csug. Back to the QDGL directory, and as soon as you have test-driven your default Debian box, you can untar your to-be-modified kernel, by running

    tar -jxvf linux-

To compile your kernel run


Your newly compiled kernel image is at arch/x86/boot/bzImage inside your kernel directory (i.e., the  directory where you untarred the kernel sources: linux- by default and assumed from now on). To test drive your new kernel run

./qemu/bin/qemu -m 64M -L ./qemu/share/qemu/ -hda hda.img -nographic -append "root=/dev/hda1 console=ttyS0,115200n8 console=tty0" -kernel linux-

Now if you login again and type   uname -a you should see that the new kernel version is

Congratulations, at this point you have managed to boot a kernel you compiled yourself !

Every time you make modifications to your linux kernel, you should rebuild it (make) and test it (./qemu/qemu ... -kernel ...).

QDG: Hidden options / tips / tricks

QDGL is free software and as such comes with no guarantees (please read the Disclaimer). Though the simple procedure suggested above should be enough to get you through your assignments, we list below a few options that might come in handy in case of bugs in the environment and in case you want to try some higher-functionality option, which hopefully will make your coding more productive. 
Need help?

Of course, you can ask the TA and the instructor for help. At the same time, we would like to encourage you to help each other, especially by using the discussion board at the blackboard. Before asking any questions though, do yourself the favor and search for the answer; most probably, one of the innumerable resources we have at hand will have quite precise directions to get you moving.