About Blog Contact

Problems with Running xv6

xv6 is an operating system by MIT’s CSAIL for instructional purposes. However, when using it with the latest versions of gcc and qemu, it would run into a dead loop when booting. Here I document the steps to solve the problem.

Clone the source code repository with:

git clone https://github.com/mit-pdos/xv6-public

With recent binutils versions, the BYTE directives produce an incorrect physical address, making it triple fault on boot. Fortunately, there’s a patch available: https://github.com/mit-pdos/xv6-public/pull/115. To download the patch, run:

curl -L "https://github.com/mit-pdos/xv6-public/pull/115.patch" > binutils_bug.patch

or click the above link in the browser if you like. The -L here is to follow the redirections.

Check for conflicts:

git apply --check binutils_bug.patch

Empty output means none. Apply the patch:

git apply binutils_bug.patch

Now we can compile and run it! Install the required toolchains (you probably already have them):

sudo apt-get install build-essential gdb

Install qemu for emulation:

sudo apt-get install qemu-system-i386

note that xv6 is a x86 OS, not a x86_64 OS.

To build it, run:


To run it, run:

make qemu

A window should pop up and a prompt should appear. You can try running a few commands, such as ls.

If you don’t what to see a GUI, run:

make qemu-nox