CS380L: Advanced Operating Systems

Lab #0

The goal of this assignment is to be able to compile and boot the Linux kernel on the KVM-qemu virtual machine.  If you have never built or installed a kernel before then please start this assignment early. We will use the Ubuntu distribution of Linux.

There are three parts to this system: the KVM-qemu virtual machine, the virtual machine's disk image, and your own build of the Linux kernel. Modern versions of Linux allow you to boot another version of Linux inside a virtual machine. In order to boot Linux you need something that looks like a disk that has all of the programs and the file system that Linux needs in order to run. Finally, we want to play with the kernel, so we want to compile it ourselves.

Unfortunately, the CS machines do not support KVM, so you will need to find a machine that does. If you can't find one, let us know.

Getting a VM running in KVM

You should be able to get your VM running inside KVM by specifying the location of the VM with -drive. You may want to append --snapshot after the file name of your VM. This ensures that no changes are made to your image during an execution so you can do something dangerous and have the original image file preserved.

Once you've been able to get your VM running inside KVM, try installing a package using aptitude to verify your VM has network access.

Obtaining and building the kernel

Download the latest Linux kernel release from kernel.org.

Installing and Copying Kernel Modules

In this step you will install the kernel modules locally and then copy them to your image. Depending on how you copy your modules, it can take a while. Feel free to build a kernel that does not need modules. Just document what options you changed from default in your write up. NOTE. For this step of the process you will need to have the guestmount package installed.

You can also use nbd to mount a qcow2 image, though I have found it terribly slow.

My favorite trick is to convert the qcow2 to a raw disk image qemu-img convert -O raw test.qcow2 test.raw, and then do a loopback mount mount -o loop,offset=32256 /path/to/image.img /mnt/mountpoint. Loopback mounts are fast.

Here is a good reference on qemu images.

Booting KVM with your new Kernel

Now that you have compiled the kernel and copied the new kernel modules to your VM, you should be able to boot your VM with the new kernel.

Your writeup