These are the basic instructions to build Arch on WSL 2.
- Installing Arch Linux for WSL2
- Install Yay AUR Helper and Pacman Wrapper
- Install and Configure Windows Terminal
- Powerline Fonts
- Launch X11 apps from the shell to Windows display
-
Install/upgrade to the
Windows Subsystem for Linux 2
. Find it on the Microsoft Store. -
Download
ArchWSL
from here. Find the.appx
and it's associated.cer
. -
Open an elevated Powershell prompt, then import the certificate.
Import-Certificate -FilePath ~\Downloads\ArchWSL-AppX_*.cer -CertStoreLocation Cert:\LocalMachine\TrustedPeople\
-
Add the package.
Add-AppxPackage ~\Downloads\ArchWSL-AppX_*
-
Then run
arch.exe
PS. You don't need Powershell anymore. Just invoke this from Windows search. -
Uncomment some servers in the pacman mirrorlist.
vim /etc/pacman.d/mirrorlist
-
Become root and refresh Arch keyring.
rm -R /etc/pacman.d/gnupg/ rm -R /root/.gnupg/ gpg --refresh-keys pacman-key --init && pacman-key --populate archlinux pacman -S archlinux-keyring pacman -Syu
-
Install base.
pacman -Syyu base base-devel git neovim aria2 fish
-
Set
root
user password.passwd
-
Create new user.
export USER=<username> && useradd -m -G wheel -s /bin/fish -d /home/$USER $USER
-
Set password on user.
passwd $USER
-
Enable
wheel
group.sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
-
Edit Arch locale and regenerate.
sed -i 's:#en_US.UTF-8 UTF-8:en_US.UTF-8 UTF-8:g' /etc/locale.gen locale-gen echo LANG=en_US.UTF-8 >> /etc/locale.conf echo LANGUAGE=en_US.UTF-8 >> /etc/locale.conf echo LC_ALL=en_US.UTF-8 >> /etc/locale.confS
-
Create a directory for the yay PKGBUILD files and enter it.
mkdir ~/yay && cd ~/yay
-
Download yay PKGBUILD from AUR.
aria2c "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yay"
-
Run
makepkg
to build and install yay.makepkg -si
Alternatively, you could use the instructions from the official Yay Github repo.
-
From the Windows Store, install Windows Terminal.
-
Edit the
settings.json
file forWindows Terminal
and add the following line to the list item:"icon" : "C:\Program Files\WindowsApps\yuk7.archwsl_22.10.16.0_x64__35zwpb4sx6e50\images\StoreLogo.png",
Download and install fonts for Powerline. Download here.
Though you can comment on this issue if you would like a section for another X server.
-
Download, install and then launch VcXsrv.
Select display settings
- Take defaultSelect how to start clients
- Take defaultExtra settings
- Be sureDisable access control
is checked.Configuration complete
- ClickFinish
-
Create a firewall rule in Windows to allow communication from WSL 2 to host OS.
New-NetFirewallRule -DisplayName "X Server - WSL 2" -Direction Inbound -Program "C:\Program Files\VcXsrv\vcxsrv.exe" -Action Allow
-
Get the IP of your local computer of the
vEthernet (WSL)
interface from CMD or PowerShell:ipconfig
-
Export output to display using IP address collected in step 3.
For
bash
andzsh
:export DISPLAY=192.168.1.100:0
For
fish
:set -x DISPLAY 192.168.1.100:0
Note: Add to
~/.bashrc
,~/.zshrc
, or~/.config/fish/fish.config
and you won't need to type it again on the next WSL launch. -
Install an xorg app for testing (We will use the Xorg Calculator).
sudo pacman -S xorg-xcalc
-
Launch
xcalc
to test.xcalc
-
If
VcXsrv
is working properly, Xorg Calculator should popup as a new window.
8. Uninstall if you want withsudo pacman -Rns xorg-xcalc
Share this with your Arch buddies that want to use Arch on their PCs as well. Link to this repo