Getting this to work (I am using Ubuntu for this) was really very simple. You will need to have QEMU installed before beginning.

1
2
sudo apt update
sudo apt install qemu qemu-system-x86

To download, build, and run Xv6, do this:

1
2
3
git clone https://github.com/mit-pdos/xv6-public.git
cd xv6-public
make qemu

Next, you will probably have to remove all the occurrences of -Werror in the repo for it to compile. If you are using an old enough complier it may work as-is. But since Xv6 is frozen in time, a historically accurate rewrite of 1970s Unix for educational use, and modern compilers expect different (more modern) coding practices, this flag will probably need to be removed before you can make Xv6.

So, use a text editor (I used Visual Studio Code) to remove all the occurrences of -Werror. There were four in total, two in the Perl script called cuth and two in the Makefile.

After that, Xv6 magically built and started running!

1
2
3
4
5
Booting from Hard Disk...
cpu0: starting 0
sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32 bmap start 58
init: starting sh
$ 

⚠️ NOTE: Xv6 is really minimal! The very basic shell doesn’t even have pwd, nor does it keep track of what directory you are in. There are only about 15 commands and they are all in the root directory.

There are only 9031 lines of actual code (counting C, Assembly, and C/C++ Header files), plus 1055 lines of comments, plus 1229 blank lines in the entire OS!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
cloc . --include-ext=c,h,S
     184 text files.
     155 unique files.                                          
     186 files ignored.

github.com/AlDanial/cloc v 1.98  T=0.03 s (2550.4 files/s, 379710.9 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               46           1029            797           6455
Assembly                         8             54            122           1734
C/C++ Header                    22            146            136            842
-------------------------------------------------------------------------------
SUM:                            76           1229           1055           9031
-------------------------------------------------------------------------------

That is really not much!

It seems that anything much I want to do with it, I will have to add it. I guess that is the point of a super-minimal teaching OS.