WSL2 installs the Arch Linux subsystem

WSL introduction and installation

Windows Subsystem for Linux(hereinafter referred to as WSL) allows developers to run the GNU/Linux environment, including most command-line tools, utilities, and applications directly on Windows, without modification and without the overhead of traditional virtual machines or dual-boot setups.

This part is mainly used WSL2as an operation object and does not involve WSL1relevant content. If you are interested in other content, please refer to Microsoft's official documentation . For updates toWSL1 , please upgrade the corresponding WSL kernel .WSL2

The above official documents provide specific installation methods, and the following section will take as Arch Linuxan example how to build other Linux subsystems that are not officially supported.

Install the Arch Linux Subsystem

Preparations before installation

From the download address on the official website of Arch, select the mirror station closest to you (for example, the Arch mirror of Tsinghua University ), and download the bootstrap mirror archlinux-bootstrap-<version>-x86_64.tar.gzwith

mirror installation

  1. First, you need to download the latest version of LxRunOffline , or quickly install it in the following two ways
scoop bucket add extras
scoop install lxrunoffline
choco install lxrunoffline
  1. Then enter the following command on the command line to install the image
# 安装名称:你想称呼你的系统叫什么名字,对应wsl启动时名称叫法
# 安装路径:你希望镜像被安装到哪里(一个你能记住的指定位置)
# 安装文件:之前下载的archlinux-bootstrap-<version>-x86_64.tar.gz文件
LxRunOffline i -n <安装名称> -d <安装路径> -f <安装文件> -r root.x86_64
# 例如我给我的镜像起名为Arch,希望安装在 D 盘根目录,则可以运行如下命令:
# LxRunOffline i -n Arch -d D:/ -f archlinux-bootstrap-<version>-x86_64.tar.gz -r root.x86_64

For other questions and detailed user manuals, please refer to the LxRunOffline documentation

If you want to install manually, you can refer to arch_linux_wsl2

System Configuration

  1. Enter the following command on the command line to start the corresponding Arch subsystem image:
# 安装名称:与安装过程中的安装名称对应
wsl -d <安装名称>
# 例如之前的过程中我将其起名为Arch,则应该执行如下命令:
# wsl -d Arch
  1. Initialize keyring
# 初始化keyring
pacman-key --init
# keyring填充
pacman-key --populate
  1. At this time, directly updating the system may not be able to resolve network problems. You need to run the following command to update the system image.
# 此处默认镜像列表为中国CN地区
# 如果是别的国家请访问:https://archlinux.org/mirrorlist/
# 可以自动生成对应的 mirrorlist
curl "https://archlinux.org/mirrorlist/?country=CN&protocol=https&ip_version=4&use_mirror_status=on" | cut -c 2- > /etc/pacman.d/mirrorlist
  1. Update the system and install the basic environment
# 更新系统
pacman -Syu
# 安装一些常用组建
pacman -S base-devel

After the above steps are completed, you can enter the subsystem as Roota user .

Set the default login user for the subsystem

Various Linux subsystems usually use rootthe user .
After we create a common user in the subsystem, we can follow the steps below to configure the default login user of the subsystem:

First of all, we need to know the name of our subsystem. We can use the following command to view all subsystems and their names in the current system:

wslconfig /list

Find the subsystem where we need to set the default user, and execute the following command on the command line to complete the change of the default login user:

# DistributionName:对应上面一步中我们查看到的系统对应的名称
<DistributionName> config --default-user <username>
# 以 ubuntu 为例,如果要设置 easternday 为默认登陆用户,则输入如下指令:
# ubuntu config --default-user easternday

Guess you like

Origin blog.csdn.net/qq_19577209/article/details/126217385