This file contains information for installing and running xv6. Please read this for your respective operating system if you were not able to previously obtain xv6 and get it running in the QEMU emulator. I strongly recommend following the instructions for linux (thus running on a linux machine or within virtual box).
For this lab we need to install an emulator that can emulate an operating system. We are using an emulator because we do not want to dedicate our personal machines to installing xv6 (although we could!). You will install this emulator on your local machines.
sudo apt-get install qemu-system-x86
See: https://www.qemu.org/download/#linux for the official instructions.
(If you have Windows 10, you can skip these steps and navigate below to ‘Install xv6’)
See: https://www.qemu.org/download/#windows for the official instructions.
See: https://www.qemu.org/download/#macos for the official instructions.
brew install pkg_config, i386-elf-gcc, i386-elf-binutils
make TOOLPREFIX=i386-elf- qemu-nox
If none of the above options work, you can try to build from source for your architecture. This is a good skill to have, but may take some time and additional configuring. See (https://www.qemu.org/download/#source) for directions.
(The official instructions are here: https://pdos.csail.mit.edu/6.828/2017/xv6.html)
We are going to run xv6 in an emulator–specifically the QEMU emulator that you built above. What this means is we now need to compile the xv6 operating system into a format that our emulator understands. If you are using linux, this is relatively straight forward. If you are not using Linux, then we need to ‘cross-compile’ the binary.
Cross-compiling means to generate a binary file that is not necessarily for our native platform. That is, if you are windows normally when you compile, executables are generaetd that run on windows. So what is different if we are on windows, is we want to generate a binary that actually is of the ELF format (which windows does not understand, but our emulator will).
Proceed to the directions below.
xv6 lives in a github repository for the MIT operating systems class.
git clone git://github.com/mit-pdos/xv6-public.git
public-xv6
folder.make
within the public-xv6 repository you have
downloaded and wait a few seconds for the OS to compile.bash install_cross.sh
)public-xv6
folder.If you have Windows 10 64-bit follow the directions below.
sudo apt-get update && sudo apt-get install git nasm build-essential qemu gdb
QEMUOPTS = -hdb fs.img xv6.img -smp $(CPUS) -m 512 $(QEMUEXTRA)
to
QEMUOPTS = -hdb fs.img xv6.img -smp $(CPUS) -m 512 $(QEMUEXTRA) -display none
If you have Windows 7 or earlier, you will need to install cygwin or some other terminal, and follow similar instructions to the Mac.
Okay great, what did we achieve? After building xv6 you should see
the fs.img and xv6.img
This is an ‘image’ of your operating
system. In other words, you whole operating system wrapped up into a
single file. The emulator (qemu) will then boot up the operating system
from within this image file, and host it in a virtualized
environment.
Okay, final step from whatever terminal you are working in.
make qemu-nox
and the operating system will begin
in your current shell! (If for some reason that does not work, you can
try make qemu
)make qemu fs.img