Setting up Windows Subsystem for Linux

February 2019 ยท 2 minute read

I briefly discussed how I am using WSL for development in my previous post, Working on Windows.

I received a few emails about exactly I got everything working, so I will attempt to detail everything here.

Assuming a fresh install of Windows 10, let’s get WSL set up!

Installing WSL

First and foremost, enable the feature. This can be done in one of two ways.

Through PowerShell:

From the start menu:

You’ll need to restart after enabling this feature.

Installing Arch Linux

Arch users will want to hang me for this, but..

Download the latest ArchWSL package. Extract wherever you feel like installing it - I personally chose ~/wsl. I am not sure if this is an issue with all WSL distros or this one specifically, but you will get an 0x8007005 error if you attempt to install it on a drive other than C:\.

So, assuming you’ve extracted it in ~/wsl:

(WIN+R) cmd
cd ~\wsl

This should have extracted the rootfs and registered it with the Lxss Manager.

Setting things up

Running Arch.exe again will drop you into a root shell.

$ visudo
    (setup however you please)
$ useradd -G wheel -m -s /bin/bash <you>
$ passwd <you>
$ pacman-key --init
$ pacman-key --populate
$ pacman -Syu
$ wget
$ pacman -U fakeroot-tcp-1.23-1-x86_64.pkg.tar.xz
$ ^D

Now we can set the default user: outside of WSL, run:

Arch.exe config --default-user <you>

To run GUI apps (such as your favorite terminal), you’ll need a few things:

$ pacman -S base-devel mesa libglvnd

You might need to add LIBGL_ALWAYS_INDIRECT=1 to /etc/environment, but I did not have to do this. You’ll definitely want some fonts, however, so I installed all-repository-fonts from AUR.

Run a GUI app

This is easy. Run vcxsrv with :0 -multiwindow -nowgl -keyhook.

You’re ready to run a GUI app now. Drop in to your shell and go to town.