1. Open your terminal/shell on your Ubuntu OS and Create a folder xv6 and cd into it. We are first creating the environment we will need to run the mini os xv6 on our laptops.
mkdir xv6
cd xv6
sudo apt update
sudo apt install -y git build-essential gdb qemu-system-x86 \
gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu qemu-system-misc
2. Now clone the repository and move into it
git clone https://github.com/mit-pdos/xv6-riscv.git
cd xv6-riscv
3. Now build the simulation and start the xv6 os
make
make qemu
4. You can now use commands like ls, mkdir on your new OS. Note that there is no relation between the xv6 folder you have created and the xv6 OS you are running. Your folder visible in your GUI mode is actually the folder which has your source code. The xv6 running is a different virtual OS running under QEMU (simulator ) like a virtual OS. See the diagram below:-
Your Laptop
│
├── Linux filesystem
│ ├── ~/xv6/
│ │ ├── xv6-riscv/
│ │ │ ├── kernel/
│ │ │ ├── user/
│ │ │ ├── Makefile
│ │ │ └── ...
│
└── QEMU
│
└── xv6
│
├── README
├── init
├── sh
├── ls
└── ...
5. Now that your xv6 has started you can explore the shell. Use ls command to see the list of commands that your current shell can run.
You see the following output:
cat – Displays the contents of one or more files on the terminal.
echo – Prints the specified text or arguments to the standard output.
forktest – Tests the operating system's process creation mechanism by repeatedly invoking fork().
grep – Searches for lines matching a specified pattern within one or more files.
init – The first user-space process started by the kernel, responsible for launching the shell.
kill – Terminates a running process using its process ID (PID).
ln – Creates a hard link to an existing file.
ls – Lists the files and directories in the specified directory.
mkdir – Creates a new directory.
rm – Removes files from the file system.
sh – The xv6 command-line shell that interprets and executes user commands.
stressfs – Stresses the file system through repeated file operations to test its reliability.
usertests – Executes a comprehensive suite of tests to verify the correctness of xv6 system calls and kernel functionality.
grind – Runs intensive process and file system workloads to uncover kernel bugs and race conditions.
wc – Counts the number of lines, words, and bytes in a file.
zombie – Demonstrates zombie processes created when a terminated child is not waited upon by its parent.
logstress – Tests the robustness of the file system logging mechanism under heavy workloads.
forphan – Demonstrates orphan process creation by allowing a parent process to terminate before its child.
dorphan – A companion program used to observe and verify orphan process behavior.
sync – Flushes buffered file system data to disk to ensure consistency.
console – Provides the kernel's console interface for handling keyboard input and terminal output.
Start by creating folders via mkdir, files via cat and use wc,ls,rm on them