Install and Configure Arch Linux in WSL/WSL2 with GUI

Student
Search for a command to run...

Student
No comments yet. Be the first to comment.
If you've ever faced the challenge of running graphical user interface (GUI) programs within a container, fear not! While it may seem like a daunting task at first, with this comprehensive guide, we'll walk through the process using Incus Container. ...

When working with containers, managing file sharing between the host system and container can often pose a challenge. However, there is an easy-to-use solution that simplifies this process using just one line of code! This blog post will guide you on...

Incus, a manager and hypervisor for system containers (LXC) and virtual machines (QEMU), is an excellent tool for managing and orchestrating your applications and services. It is a fork of LXD by the original maintainers. I found the documentation re...

Using ble.sh and Starship. Bash by itself is pretty basic. Syntax highlighting, auto-suggestion and history matching are pretty helpful features in any shell. Users might be worried about the bloat these features bring and add delay to the startup of...

The ability to run virtual machines (VMs) and docker containers is an integral part of today’s modern computing landscape. However, issues with internet connectivity inside these environments often cause significant inconvenience for users who depend...

This post is divided into two parts: (i) Install Arch in WSL, (ii) Configure as per your needs. Each part can be followed independently so if you are not a fan of GUI programs in WSL, leaving the part is perfectly fine.
Download and install Linux kernel updae package from Microsoft's site. Set default version to WSL2 by running
wsl --set-default-version 2
Assuming you have Scoop installed, this part reduces to
scoop install archwsl
Head to https://github.com/yuk7/ArchWSL/releases and download the .appx and .cer files.
Now double click the .cer file and follow the prompts to install the certificates neecssary for the installation of Arch WSL. When done, double-click the .appx file to install it.
Once there, open Arch from Start menu and let it install. When done, you should see an installation complete message. If you encountered problems with the installation, see the issues at https://github.com/yuk7/ArchWSL/issues. If there is none, feel free to open an issue.

Open Arch again. It should be logged in as root.
Uncomment the servers closest to your region in /etc/pacman.d/mirrorlist. Now run pacman -Syyu to fetch and install updates.
If you get invalid or corrupted package (PGP signature) error, do not delete the downloaded packages. Run the following commands one by one as root
rm -R /etc/pacman.d/gnupg
rm -R /root/.gnupg/
gpg --refresh-keywordspacman-hey --init && pacman-key --populate archlinux
pacman -S archlinux-keyring
pacman -Syyu
It should install fine.
Running everything as root on a normal machine is a pretty stupid idea. Create a normal user:
useradd -m -g users -G wheel,storge,power -s /bin/bash <username>
It will add a user with whatever you used in <username>. Set a password for this user with
passwd <username>
Uncomment the following line after running visudo:
%wheel ALL=(ALL) ALL
First, we install xorg, xorg-server and then xfce4. You may install a desktop environment of your choice.
pacman -S xorg xorg-server
pacman -S xfce4
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
export LIBGL_ALWAYS_INDIRECT=1
While the DE is being installed, grab VcXsrv or (again) you should be fine with your favourite X Server. Alternativaly it can be installed via scoop with
scoop install vcxsrv
Hit Win+Q, type XLaunch and hit Enter. Once there, select One Large Window (just for the sake of it, if you wish to see the DE in action). Check Disable access control, leave the rest as is and click Next ad then Finish. Allow access if prompted by firewall.


