Installing Arch on WSL2 the Right Way (2023)

Getting the bootstrap image from official mirrors

Open up the terminal and download the archlinux bootstrap tarball

Invoke-WebRequest -Uri "" -OutFile "$HOME\Downloads\archlinux-bootstrap.tar.gz"

Extract and repackage the downloaded bootstrap file in another Linux distro, e.g. WSL Ubuntu

cd /mnt/c/Users/micha/Downloads/mv archlinux-bootstrap.tar.gz ~cdtar -zxvf archlinux-bootstrap.tar.gzcd root.x86_64tar -zcvf arch_bootstrap_repackage.tar.gz .mv arch_bootstrap.tar.gz /mnt/c/Users/micha/Downloads/

Pick an installation location

Once the tarball is finished downloading, it is time specify the location for Arch Linux .vhdx container file. Create a directory in you home folder labeled “wsl”. Make sure that each distro has their own location.

md "$HOME\wsl"

You may have to create subdirectories as well.

'kernel', 'distributions\arch', 'distributions\ubuntu', '.backup' | % {New-Item -Name "\$_" -ItemType 'Directory'}

If you do go the route of setting up subdirectories, the one labeled “.backup” should be made hidden.

$f=get-item $HOME\wsl\.backup -Force$f.attributes="Hidden"

The reason for this is that wsl requires a user with admin permissions, and if you have more than one admin user, each user needs to have their own Arch install. While it may be possible to have more than one user account, wsl is not set up for that and the default user that you would have to boot into would be the root user, which is not a good idea.

Importing and System Update

Import the tarball requires an installation location with no other distro, or otherwise it will fail.

wsl --import Arch "$HOME\wsl\distributions\arch" "$HOME\Downloads\arch_bootstrap_repackage.tar.gz"

When importing the tarball is complete, run wsl -d Arch. You will be greeted with a root user prompt. Before anything is done, switch to the home directory cd ~ because what is going to happen cannot be done in the home folder of you Windows profile.

The first thing we need to do is to make pacman work.

sed -i 's:#Server:Server:g' /etc/pacman.d/mirrorlist

Now let’s enable multilib, which is required for most development packages.

linenumber=$(grep -nr "\\#\\[multilib\\]" /etc/pacman.conf | gawk '{print $1}' FS=":")sed -i "${linenumber}s:.*:[multilib]:" /etc/pacman.conflinenumber=$((linenumber+1))sed -i "${linenumber}s:.*:Include = /etc/pacman.d/mirrorlist:" /etc/pacman.conf

The keyring needs to be initialized and populated.

pacman-key --init && pacman-key --populate archlinux

Now it’s time to update the currently installed packages. After that we’ll enable installing from the AUR and make systemd work.

pacman -Syu --noconfirm

Due to some changes implemented with systemd version 250 and higher, distrod is not fully compatible with the latest systemd version. In order to make distrod work correctly, systemd needs to be downgraded.

List of Ignored Packages:

  • systemd
  • pciutils
  • hwdata
  • systemd-libs
  • systemd-sysvcompat

Now downgrade systemd.

pacman -U --noconfirm

Install some required packages.

pacman -S --noconfirm base-devel git vim nano wget reflector sudo which go openssh man-db bash-completion fontconfig ntp

Configure pacman to use the fastest and most up-to-date mirrors. Replace Germany with your host country, if necessary.

reflector --country "Germany" --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

Setting Up User Account

Setting up a user account is the same as in a bare metal Arch installation. However, only one user can be set per logged Windows profile. With sudo installed, a sudoers file in the etc directory now exists. This file needs to be edited so that the user can run most root commands without having to log in as the root user.

In order to edit the file, you need to tell sudo which text editor to use.

export EDITOR=vim ; visudo

Installing Arch on WSL2 the Right Way (1)

Uncomment the line containing %wheel ALL=(ALL) ALL; do the same to the next line with %wheel if you want to run sudo tasks without having to provide your password.

Now set the root user password with passwd. Do this before setting up the login user account. Once the root user has a password, create a user and prompt to set a password.

useradd -m -G wheel -s /bin/bash -d /home/michael michael ; passwd michael

Because Archlinux was imported, by default the login user is the root user even with a user account. To prevent this, a config file needs to be created to tell wsl which user to log in. Create the file /etc/wsl.conf and copy the following, replacing ‘michael’ with your own username.

[automount]enabled = trueoptions = "metadata,uid=1000,gid=1000,umask=22,fmask=11,case=off"mountFsTab = truecrossDistro = true[network]generateHosts = truenning with systemd, otherwise# false.generateResolvConf = true[interop]enabled = trueappendWindowsPath = true[user]default = michael

Enabling SystemD

Because of how wsl boots Linux, systemd is not started. This prevents ssh-logins and testing out systemctl scripts and functions. It is, however, possible to get systemd to boot when you log in. There are several ways to go about this; one is to enable through namespace and the other is with an application name distrod.

You can follow the guide from the GitHub page; however, if you what to start Arch when Windows starts up or when you log on and stay running even when you close the terminal, then there are some different steps to take, though only recommended if you bare metal system has 16GB of RAM or more.

Installing distrod.

curl -L -O ""chmod +x ; ./ install

Now enable distrod.

/opt/distrod/bin/distrod enable

The next thing to do is restart Arch. Enter exit and you should be back in the PowerShell prompt. If you log in immediately after, the wsl settings will not take effect. To force wsl to enable /etc/wsl.conf, run wsl --shutdown Arch and then restart Arch.

If you use Windows Terminal, the best way is close the application, then reopen it; a new profile for Arch has been added. To change the starting directory for Arch, goto settings and locate the profile for Arch. Find “Starting Directory” and replace it with \\wsl$\Arch\home\michael, replacing ‘michael’ with your own username. Then click save.

Now it is time to start Arch and see if systemd is running.

sudo systemctl status

If systemd is functional, you should see a green indication, and you can create your own systemctl scripts, but before that, let’s first enable some services.

sudo systemctl enable --now dbus.service ntpd.service sshd.service

Enable port forwarding so that you can access Arch from outside wsl.

echo 22 80 443 | sudo tee /opt/distrod/conf/tcp4_portssudo systemctl enable --now portproxy.service

Installing Paru to comfortably access the AUR (Arch User Repository)

git clone paru-binmakepkg -si --noconfirm

Adjust locale

sudo vim /etc/locale.gen

uncomment de_DE.UTF-8 UTF-8 and en_US.UTF-8 UTF-8

Then run


Bonus Level: Boot Arch when You Log into Windows

Getting wsl to start when you log in to Windows is pretty simple even though you have to use Task Schedule. If you liked the idea of Arch booting before open Windows Terminal or start VSCode and enable this through distro that task will have to be removed. Besides, the script that is used doesn’t all wsl to persist after you close an application.

While logged into Arch create a visual basic script.

echo 'set object = createobject("") "wsl.exe --distribution Arch", 0' > /mnt/to/same/location/of/arch/install/dir/boot-arch-at-logon.vbs

Now goto the search box in the taskbar and enter in Task Schedule and click on “Run as administrator.” If allowed distrod to set the task your going to have to remove it first. Highlight “Task Schedule Library,” goto the available task to the right and locate one that has “StartWSL_Arch_for_.”

Installing Arch on WSL2 the Right Way (2)

Now delete the task.

The next step is the setup a new task, start by highlighting “Task Schedule Library” again and click on “New Folder…” and naming it WSL. Now when you expend the library you should see the new folder.

Installing Arch on WSL2 the Right Way (3)

Hightlight the folder and select “Create Basic Task” and follow the points below for task settings.

  • Task Name: Start Arch at Login
  • Triggers: At log on
  • Start program: (Drive letter):\path\to\boot-arch-at-logon.vbs
  • Conditions: Unchanged
  • Settings: Uncheck, “Stop task if it runs longer then.”

Save the task if you want the test it out the reboot the machine, once you log back in open up the PowerShell profile of Windows Terminal and run the Get-Process command. You should see 2 or 3 processes, one for wsl and the others wslhost; the later is Arch.

With all that done, you are ready to enjoy Archlinux.

Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated: 15/10/2023

Views: 6221

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.