Setting up Arch Linux as a WSL instance

Praharsha
2 min readJul 30, 2020

--

A guide on getting started with Arch on Windows Subsystem for Linux. This guide is mainly written with WSL1 kept in mind, the procedure is more or less the same for WSL2 with few changes.

I’ll be using ArchWSL. Grab the latest package for WSL1 here, (Arch for WSL2 is still in testing phase and is in active development) two different packages are provided, you can choose between .zip or .appx and follow the instructions accordingly.

NOTE: Keep in my mind that if you plan to install additional packages (as you would so) make sure you have got enough space on C drive; however if you wish to install to a different location, you can easily do so, i have already written about it here :)

I assume you’ve already enabled WSL

Initial Setup

  • Initialize pacman keyring:
pacman-key --init (for package validation)
pacman-key --populate archlinux

Run again if it fails…

  • Pick a mirror in /etc/pacman.d/mirrorlist
echo 'Server = http://archlinux.de-labrusse.fr/$repo/os/$arch' >> /etc/pacman.d/mirrorlist (french server for instance)
  • Set up timezone, localization
  • Add a DNS server to /etc/resolv.conf (Eg: 8.8.8.8 & 8.8.4.4)
  • pacman -Syy

Fix fakeroot for WSL1 (Most important!)

Wait you cannot build packages yet…! the standard fakeroot doesn’t work with WSL 1 as Microsoft hasn’t implemented Unix SYSV IPC, which is used by fakeroot (unless you’re using WSL 2 which runs an actual Linux kernel)

The fix is to use fakeroot-tcp from AUR which uses TCP/IP sockets instead of Unix IPC, the real problem is you need fakeroot itself (to simulate superuser privileges) inorder to build it…

There are many workarounds. One obvious way is to build it on a real ArchLinux machine, pass it over and install.
But to avoid complications, you can obtain the pre-built package from any trusted source.

wget https://github.com/yuk7/arch-prebuilt/releases/download/18082100/fakeroot-tcp-1.23-1-x86_64.pkg.tar.xzpacman -U fakeroot-tcp-1.23-1-x86_64.pkg.tar.xz

See Known-issues#fakeroot

Install development tools

  • pacman -S base-devel (Choose Default=ALL)
  • pacman -S git
  • pacman -Sy wget

You can install additional tools like python, docker, htop etc…

Create User

useradd -m -g users -s /bin/bash your_user_name
passwd your_user_name
usermod -aG wheel your_user_name

Add user to sudoers list

nano /etc/sudoers%wheel ALL=(ALL) NOPASSWD: ALL

Change the default user:

Arch.exe config — default-user your_user_name

Installing AUR Packages Manually

The development tools installed in the earlier step will help us to compile

  • Search for the package in AUR
  • Clone the repository with git. git clone <Git Clone URL>
  • (Optional) check PKGBUILD file
  • Change to the cloned directory; compile and install using makepkg -si

You can install a helper like yay,yaourt or pacaur to make this process easier

Please go through Known-issues on ArchWSL repo to fix other commonly faced issues with D-Bus, systemd/systemctl etc..

--

--

Praharsha

I’m a Computerphile and have been into computers and OS related things from a very early age. I love anything tech related!