Sunday, February 21, 2016

Installing and Running xv6 Operating System

xv6 running on QEMU
When learning advanced concepts of operating systems, it is interesting to look at the source code of a real operating system. However unfortunately, most of the open source operating system source codes are so huge and it is not an easy job to read the code and understand how certain things are implemented. In a situation like that, it is important to have something much smaller in size while providing all the necessary ingredients of a real operating system.

xv6 is an operating system developed by MIT for the exact same purpose. It is an implementation of the Unix version 6 using ANSI C language for x86 platforms. It is a great resource for learning operating systems and many universities all over the world have already used it in their courses. Here's how we run xv6 operating system on a QEMU virtual machine simply on top of a 64-bit Ubuntu 14.04 LTS machine.

First of all, we have to install some tools and packages on our Ubuntu Linux system as follows.

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install gcc-multilib
sudo apt-get install qemu
sudo apt-get install git

Now, let's download the source code of the xv6 operating system. MIT provided an official git repository to download the source code. However, I have cloned it into a my own repository on Github from where I will get it.

git clone https://github.com/asanka-code/xv6.git
cd xv6

After moving into the directory with the source code, we need to make an important entry inside the Makefile. Therefore, find the line which has the QEMU command and update it to make it look like as follows.

QEMU = qemu-system-x86_64

Time to compile and run xv6 system on QEMU emulator.

make
make qemu

This will startup a window with QEMU emulator and will start the shell prompt of xv6 operating system.

References:

[1] Frans Kaashoek. 6.828 Operating System Engineering, Fall 2012. (Massachusetts Institute of Technology: MIT OpenCourseWare), http://ocw.mit.edu (Accessed 22 Feb, 2016). License: Creative Commons BY-NC-SA

[2] http://janfan.github.io/english-blog/english/2014/06/17/how-i-learn-os.html

3 comments: