Installation instructions for Arch Linux in WSL2
These are installation instructions for Arch Linux in WSL2 using the officially built bootstrap image.
wsl --set-default-version 2
(version 2 is set by default in newer windows builds)In an existing linux install (another WSL distro, VM, or native), download the archlinux-bootstrap-<version>-x86_64.tar.gz
bootstrap image from an arch mirror closest to you.
AS ROOT via sudo or a root user, run the following commands:
tar -zxvf archlinux-bootstrap-<version>-x86_64.tar.gz
cd root.x86_64
tar -zcvf arch_bootstrap.tar.gz .
The reason this must be done as root is to preserve file ownership of bootstrap filesystem when it is imported into WSL. If this is not done, you will likely experience permissions issues when interacting with imported the operating system.
Once the new archive is created, move the file to the machine Arch will be installed on (copy to usb drive, or move out of existing WSL).
On the machine Arch will be installed on:
wsl --import Arch C:\Users\{USER}\wsl C:\path\to\arch_bootstrap.tar.gz
Arch can now be launched on the machine it was installed on. Some additional configuration will be needed to make this a fully functional arch install:
wsl -d Arch
pacman-key --init
pacman-key --populate archlinux
curl "https://archlinux.org/mirrorlist/?country=US&protocol=https&ip_version=4&use_mirror_status=on" | cut -c 2- > /etc/pacman.d/mirrorlist
pacman -Syu
pacman -S base base-devel
From here, you can continue setting up your new Arch Linux based WSL2 installation by following the Installation Guide. It is probably a good idea to set your locale, hostname, and to create yourself a new user to use. Keep in mind that you will not need to worry about your fstab
or bootloader to use Arch in WSL. Installing an aur helper is also a good idea.
Additionally, if you use Windows Terminal you can set Arch to launch with your new user in its home directory by adding "commandline": "wsl ~ -u <username>"
to the profile in the profile list. Arch must be the default WSL installation for this to work (which can be done with wsl --set-default Arch
.