No blow no black, WSL is YYDS, CentOs8 on the cloud server to make a long time, all kinds of source code compilation, as WSL with Ubuntu16.04 half an hour easy to fix, but there are some pits, this is a record, so the best look after start to get.

1. Enable WSL for Windows.

Control Panel -> Programs -> Enable or Disable Windows Features.

√ Select Windows Subsystem for Linux and VM Platform. The latter is required by WSL2.

2. Install Ubuntu16.04 LTS

Open the Windows PowerShell,

Wsl-l-o Views the valid distribution available for installation

WSL –install -d Ubuntu 16.04 install Ubuntu 16.04

When the installation is complete, a screen will pop up, asking you to enter the UNIX user name, password, etc. Note that the new Ubuntu system requires sudo passwd to activate root and set the password (it is not the same as the initial password, but you can set it to the same password for easy memory). After the configuration is complete, su can be converted to root user.

At this point, you should be able to play happily on Ubuntu, but the shell is too ugly. Windows Terminal is recommended. You can log in to Ubuntu directly from Powershell by using the “WSL” command, or by pulling down and clicking directly

3. Install qume and necessary dependencies

Before installation, it is recommended to change apt-get into domestic sources, tutorials casually find on the line

Sudo apt-get install qume

sudo apt-get install -y build-essential gdb

sudo apt-get install gcc-multilib

/usr/bin = qume-system-xxx; /usr/bin = qume; /usr/bin = qume

4. Download and compile Xv6

Git clone git://github.com/mit-pdos/xv6-public.git && CD xv6-public

Git checkout -b xv6-rev7 xv6-rev7 git checkout -b xv6-rev7

Vim Makefile Modifies the Makefile file by specifying the QEMU path QEMU = qemu-system-x86_64

makeCompile directly!

5. Upgrade WSL2

syntax error: word unexpected (expecting “)”)

I found a syntax error in the Makefile when I was writing code, and then I went to baidu to look, but I couldn’t see anything. There were probably several blogs saying that the compiler had a problem. As specified in makeFiles, I understand that the same code will fail to compile (compatibility issues) as py2 and Py3 have syntactical differences, but I don’t see a unified solution.

Then it occurred to me that WSL1 might be the problem, and WSL2 is the real Linux kernel. Try upgrading.

Comparison of WSL 1 and 2 | WSL Microsoft Docs

The old manual installation steps of WSL | Microsoft Docs

Reference above tutorial basic no problem

WSL –set-version Ubuntu-16.04 2 Upgrade Ubuntu version to 2

Wsl-l -v Displays the current Distribution and details to confirm the upgrade.

Finally, run WSL2, go to /xv6-public, and open make! In theory there will be no more errors.

6. Run xv6

Run a very simple make qemu-nox command. See the following figure, which basically means that you have succeeded. Try some basic commands like ls and echo.

One thing worth mentioning is, how do you exit? Everyone says CTRL + A and x exits QEMu, but it’s really not that easy to misinterpret as pressing together.

The correct action is to press CTRL + A, release, and then press X to exit QEMU, instead of pressing 3 keys.