Windows 的 Linux 子系统之 Arch Linux
WSL Arch
![](/data/attachment/album/201610/12/224452hxxh8zhc4w449cm7.jpg)


Ubuntu 的制造商 [Canonical](http://www.canonical.com/) 早已和微软进行合作，让我们体验了极具争议的 [Bash on Windows](https://itsfoss.com/bash-on-windows/)。外界对此也是褒贬不一，许多 Linux 重度用户则是质疑其是否有用，以及更进一步认为 [Bash on Windows 是一个安全隐患](https://itsfoss.com/linux-bash-windows-security/)。


Unix 的 Bash 是通过 WSL (<ruby> Windows 的 Linux 子系统 <rp>  （ </rp> <rt>  Windows Subsystem for Linux </rt> <rp>  ） </rp></ruby>) 特性移植到了 Windows 中。早先，我们已经展示过 [安装 Bash 到 Windows](/article-7209-1.html)。


Canonical 和微软合作的 Bash on Windows 也仅仅是 Ubuntu 的命令行而已，并非是正规的图形用户界面。


不过，有个好现象是 Linux 爱好者开始在上面投入时间和精力，他们在 WSL 做到的成绩甚至让最初的开发者都吃惊，“等等，这真的可以吗？”。


这个正在逐步实现之中。


![](/data/attachment/album/201610/12/224512xok8kpkpw7qn48nc.jpg)


没错，上图所示就是运行在 Windows 中的 Ubuntu Unity 桌面。一位名为 Pablo Gonzalez （GitHub ID 为 [Guerra24](https://github.com/Guerra24) ）的程序员将这个完美实现了。随着这个实现，他向我们展示了 WSL 已经超越了当初构想之时的功能。


如果现在可以在 Windows 子系统之中运行 Ubuntu Unity，那么运行其他的 Linux 发行版还会远吗？


### Arch Linux 版的 Bash on Windows


在 WSL 本地运行完整的 Linux发行版，迟早是要实现的。而我最希望的就是 [Arch Linux](https://www.archlinux.org/) （[Antergos](https://itsfoss.com/tag/antergos/) 爱好者点击此处）。


![](/data/attachment/album/201610/12/224533q6pmprpm79398f3s.jpg)


Hold 住，Hold 住，该项目目前还在测试中。它由“mintxomat”在 GitHub 上开发的，最新为 0.6 版本。第一个稳定版将在今年的 12 月底发布。


那么，该项目的出台会有什么不同呢？


你可能早就知道，WSL 仅在 Windows 10 中可用。但是 Windows 的 Linux 子系统之 Arch Linux (AWSL) 早已成功的运行在 Windows 7、Windows 8、Windows 8.1 和 Windows Server 2012(R2)，当然还有 Windows 10。


我靠，他们是怎么做到的？！


其开发者曾说，AWSL 协议抽象归纳了不同 Windows 版本的各种框架。所以，当 AWSL 发布 1.0 应该会取得更大的成绩。如我们之前提到的移植性，该项目会先向所有 Windows 版本推出 Bash on Windows。


该项目很有雄心，并且很有看头。如果等不及 12 月底的稳定版，你可以先行尝试其测试版。但要记住，目前还是开发者预览版，此刻并不稳定。但是，我们什么时候停止过折腾的脚步？


你也可到 GitHub 查看此项目的进度：[Arch on Windows Subsystem](https://github.com/turbo/alwsl)


分享本文，以便大家都知道 Arch Linux 即将登陆 Windows 子系统。同时，也告诉我们，你希望 WSL 中有什么发行版。




---


via: <https://itsfoss.com/arch-linux-windows-subsystem/>


作者：[Aquil Roshan][a] 译者：[GHLandy](https://github.com/GHLandy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

[WSL](https://itsfoss.com/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.

[this GitHub](https://github.com/badgumby/arch-wsl)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](https://itsfoss.com/content/images/2024/04/click-on-any-mirror-link.png)

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](https://itsfoss.com/content/images/2024/04/right-click-and-copy-bootstrap-link.png)

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.](https://itsfoss.com/content/images/2024/04/downloading-and-later-lisitng-the-arch-linux-bootstrap-tar-file.png)

Extract the tar file [using the tar command](https://linuxhandbook.com/basic-tar-commands/):

```
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.

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](https://itsfoss.com/content/images/2024/04/uncomment-selected-servers.png)

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](https://itsfoss.com/content/images/2024/04/compressed-arch-linux-file-with-changed-mirrors-file.png)

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](https://linuxhandbook.com/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](https://itsfoss.com/content/images/2024/04/mv-the-compressed-tar-file-to-a-windows-location.png)

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](https://itsfoss.com/content/images/2024/04/open-terminal-as-admin.png)

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](https://itsfoss.com/content/images/2024/04/importing-wsl-distribution.png)

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.](https://itsfoss.com/content/images/2024/04/installed-distribution-lists-arch-linux.png)

Log in to Arch Linux system using the command:

```
wsl -d ArchLinux
```


`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](https://itsfoss.com/content/images/2024/04/running-whoami-command-in-arch-linux-wsl.png)

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](https://itsfoss.com/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.](https://itsfoss.com/content/images/2024/04/locale-gen-file-uncomment-us.png)

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](https://itsfoss.com/content/images/2024/04/update-password-root.png)

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 t[he useradd command](https://linuxhandbook.com/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.](https://itsfoss.com/content/images/2024/04/visudo-edit-add-wheel-permission-1.png)

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](https://itsfoss.com/content/images/2024/04/arch-wsl-neofetch.png)

## 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 WindowsGet started with Linux within the comfort of your Windows system with WSL. Learn the essential WSL concepts.](https://itsfoss.com/wsl/)![](https://itsfoss.com/content/images/2024/07/using-wsl.png)


![](https://itsfoss.com/content/images/2024/07/using-wsl.png)

Enjoy :)