Using Arch Linux With WSL

While Arch Linux is not officially available on WSL, you can use it with some extra efforts with this project.
Warp Terminal

WSL feature allows running an actual Linux distribution inside Windows. Ubuntu was the first distro that could be installed this way. Soon, SUSE, Kali Linux and some other Linux distributions joined the WSL bandwagon.

However, Arch Linux is not officially available on WSL, but if you make some efforts, you can use it via WSL.

In this article, I show a method to set up Arch Linux WSL system under WSL 2.

πŸ“‹
The methods mentioned in this GitHub repo is referenced in part in this article.

There are some prerequisites.

  • A WSL Linux distribution (Ubuntu, recommended) is installed.
  • You should be running WSL version 2.

Here, I'll be using the Arch Linux Bootstrap Tar file to set up the WSL system.

Step 1: Setting the Arch Linux Import File

First, head over to the Arch Linux website and go to the download page. From the download page, select an appropriate mirror.

Click on any mirror on the Arch Linux downloads page according to your location preferences
Go to an Arch Linux Download Mirror

Inside that, you can find several Arch Linux files. Right-click on the x86_64 bootstrap tar file and select copy link.

Right click on the Arch Linux bootstrap tar file link and select copy link option from the context menu
Copy the Arch Linux Link

Now, open an existing WSL distribution (let's say you are running an Ubuntu WSL system) from the start menu or from the terminal:

wsl ~ -d <distribution_name>

Inside the distro, use the wget command to download the Arch Linux Tar file.

wget <copied link to the tar file>

This will download the tar file to the home directory of the current user. Once download completed, use ls command to list the contents and get the name of the downloaded file.

ls
Downloading the tar file for Arch Linux. Later, it is listed on the directory.
Download the Arch Linux File
🚧
For the commands below, that are being run with sudo privileges, should be executed with sudo commands. Skipping admin privilege may make several unexpected permission variations to various directories. This may result in errors when the system is imported at a later stage.

Extract the tar file using the tar command:

sudo tar -zxvf <downloaded file name>

Thereafter, enter into the extracted folder using the cd command:

cd <name of the extracted folder>

Here, in my case, it is:

cd root.x86_64

Inside the directory, spot the file on etc/pacman.d/mirrorlist. This file holds the list of mirrors. Initially, all the entries are commented. You need to uncomment some mirrors from the list.

While uncommenting, you can choose those in your country and near your country.

🚧
Remember some mirrors may not work all the time.

Since you are inside another WSL distro, use nano editor to edit the file.

sudo nano etc/pacman.d/mirrorlist
Edit the mirror file and uncomment selected servers
Editing the Mirrors file

After uncommenting some mirrors, save the file using CTRL+O and then exit the editor using CTRL+X.

Now, compress the whole root folder back to the tar.gz file. For this, you should be inside the root.x86_64 directory and run the command:

sudo tar -czvf root.tar.gz *

This will create a compressed file containing the contents of the folder, including the changes you have made to the mirrors file. If you list the contents, you can spot the tar file.

Newly compressed file inside the root.x86_64 directory, that contains the modified mirror file
Newly compressed file inside the root directory

What you need to do is, move this file to a location where it is easily accessible via a Windows terminal. For this, you can use the mv command. On the current folder, that is, where you have created the tar file, run:

sudo mv root.tar.gz <name of the Windows folder>

Windows directories are available inside the WSL distribution, and you can access them from /mnt. So, for me, I have created a location to save the tar file on my drive, and I will use the command:

sudo mv root.tar.gz /mnt/d/WSL_Exports/

This will save the tar file to a folder called WSL_Exports on my D: Drive.

Copy the tar file on user's home directory using the cp command
Copy the file to a Windows location

You now have the Arch Linux import file.

Step 2: Import Arch Linux

Once you have the tar file ready, you can close the current WSL distribution by running on a Windows terminal.

wsl --terminate <distribution_name>

Now, open a terminal in Windows as administrator.

Open Windows terminal in administrator mode
Open Terminal as Administrator

Run the following command to import the Arch Linux distribution.

wsl --import ArchLinux <Location to where imported> <Location of the tar file>

The installation location can be any convenient place, that you can easily distinguish for later accessibility. So, I may use the command:

wsl --import ArchLinux D:\WSL_Imports\ D:\WSL_Exports\root.tar.gz
Importing Arch Linux using wsl import command
Importing Arch Linux

This will import the distribution. You may need to wait for some time to finish the importing process.

Step 3: Set up Arch Linux

Once the import is completed, you can list the installed WSL distributions to verify Arch Linux is listed among them.

wsl -l -v
Installed distributions are listed, and Arch Linux is one of them.
Arch Linux Installed

Log in to Arch Linux system using the command:

wsl -d ArchLinux
🚧
You should use the name of the distribution exactly same as the one appearing on the wsl -l -v command.

Once inside the system, enter the command:

cd

To take you away from the mounted Windows directory. Here, you can see that, you have been logged in as the root user, but nothing is set up, including the root password.

Running `whoami` command on Arch Linux instance
Logged in as Root

So we will be taking care of those things in the next step.

Initialize keyring and update system

First, initialize the Arch Linux keyring:

pacman-key --init
pacman-key --populate archlinux
pacman-key --refresh-keys
pacman -Sy archlinux-keyring

Thereafter, run a system update using:

pacman -Syu

Now, it's time to install the base and other essential packages. You can use the pacman command for the purpose.

pacman -Syu base base-devel git nano wget reflector rsync

You can update the mirror list using reflector. For this, first back up the existing mirror list, in case anything goes weird.

cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak

Now, get the good mirror list with reflector and save it to mirrorlist. Below, I have added two mirror countries, US and Canada, using repeated -c option.

reflector -c us -c ca -f 12 -l 10 -n 12 --save /etc/pacman.d/mirrorlist

You can change the country from US to your own country. Get a list of reflector countries and codes using the command:

reflector --list-countries

Setting up locale

The language, numbering, date, and currency formats for your system depends on this setting.

The file /etc/locale.gen contains all the local settings and system language in a commented format. Open the file using:

nano /etc/locate.gen

I have used en_US.UTF-8 (English United States). Uncomment that particular line. Now, save the file (CTRL + O) and exit the editor (CTRL + X).

Uncomment the US locale entry on the locale.gen file.
Edit locale-gen file

Generate the locale config in the /etc directory file using the below commands one by one:

locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8

Root user password and normal user creation

Since you currently haven't a root password set up, do that by using the passwd command:

passwd

Type and retype the password to make the change effect.

Passwd command and password verification for Root
Add Root Password

It is not recommended to log in as the root all the time. It can be catastrophic for your system, as there are chances for accidental changes taking effect immediately. So, you need a regular user, who can run administrative commands when needed.

In Arch Linux, you can use the useradd command, to create a new user. Let's create a new user called β€œteam”.

useradd -m team

Here, the -m option will automatically create a home directory for the user at /home/.

Set a password for the user β€œteam”, using:

passwd team

Type and retype password to confirm the change.

Once the user is created, add that user to the wheel group so that he can run the sudo command to access some administrative privileges.

usermod -aG wheel team

But at this point, the wheel group cannot run all the commands. For this, you need to allow the members of the wheel group to run any commands.

We will edit the sudoers file for this.

EDITOR=nano visudo

The above command will open the visudo in nano editor. Locate the line %wheel ALL=(ALL) ALL and uncomment it.

Uncomment the permission settings for the wheel group in visudo.
Edit Wheel Group Permission

Save the document using CTRL + O and exit using CTRL + X.

At this point, you can just terminate the system using the command:

wsl.exe --terminate ArchLinux

And then reopen it from a Windows terminal.

wsl ~ -d ArchLinux -u team

Here, we are directly logging in as the normal user (team), that was created in the previous step. The ~ option will land you straight in the home directory of the user.

Or, you can create a file inside the Arch Linux system by running the following command:

sudo nano /etc/wsl.conf

Inside this file, add the line:

[user]
default = team

This will set the user β€œteam” as the default one. You will no longer be logging in as the root.

Now, save the file and exit. Terminate the system using the command:

wsl.exe --terminate ArchLinux

Now, you can restart the system by:

wsl ~ -d ArchLinux
Neofetch output for Arch Linux running in WSL
Arch Linux in WSL

Wrapping Up

As you can see, this is certainly not the easiest way to get on with WSL. Use it only if you really want Arch Linux for some reasons or you want to test your technical capabilities.

By the way, if you are new to WSL, do check out our WSL series.

Using Linux With WSL on Windows
Get started with Linux within the comfort of your Windows system with WSL. Learn the essential WSL concepts.

Enjoy :)

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries πŸ•΅οΈβ€β™‚οΈ

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.