Archlinux WSL Installation and Configuration

Page content

Perhaps installing Windows Subsystem for Linux (WSL) from the Windows Store is the easiest way, and this method will install WSL (such as Ubuntu) on the Windows system drive by default. However, this will compress the storage space of the system drive, so sometimes we want to install WSL on other disk partitions. Here, taking archlinuxwsl as an example, we introduce a general process of installing WSL.

1. Install Archlinux

1.1 Enable the Windows Subsystem for Linux

# Open PowerShell with administrator privileges and enter the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

1.2 Enable Virtual Machine feature

# Open PowerShell with administrator privileges and enter the following command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

1.3 Download and install the Linux kernel upgrade package

Download link —> https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

1.4 Set WSL2 as the default version

# Open PowerShell with administrator privileges and enter the following command:
wsl --set-default-version 2

1.5 Download LxRunOffline

Download link —> https://ddosolitary-builds.sourceforge.io/LxRunOffline/LxRunOffline-v3.5.0-11-gfdab71a-msvc.zip

1.6 Download and install ArchlinuxWSL

Download link —> https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz

In the Windows terminal, navigate to the LxRunOffline folder and run the following command:

# LxRunOffline i -n <your_wsl_name> -f <The path of ArchLinux ISO> -d <The path to install the system> -r root.x86_64
LxRunOffline i -n archlinux -f D:\WSL\archlinux_img\archlinux-bootstrap-2021.10.01-x86_64.tar.gz  -d  D:\WSL\archlinux -r root.x86_64

1.7 Enter ArchlinuxWSL

wsl -d <your_wsl_name>
wsl -d archlinux

2. Configuration ArchlinuxWSL

2.1 Change the source

# Configure domestic mirror sources.
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
sudo vim /etc/pacman.d/mirrorlist
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch

# Configure domestic community mirror sources.
sudo cp /etc/pacman.conf /etc/pacman.conf.backup
sudo vim /etc/pacman.conf
[archlinuxcn]
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

# Install keyring
sudo pacman -S archlinuxcn-keyring

# Update the system.
sudo pacman -Syyu

2.2 Install and configure Zsh

# install zsh
yay -S zsh

# install oh-my-zsh
wget -c https://fastly.jsdelivr.net/gh/sdy2813/bioprogram@main/Linux/zsh_install.sh

zsh zsh_install.sh

# Add plugins.
# zsh-syntax-highlighting
git clone https://gitclone.com/github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# zsh-autosuggestions
git clone https://gitclone.com/github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# modify ~/.zshrc
plugins=(git zsh-autosuggestions zsh-syntax-highlighting z extract)
# set the terminal supports 256 colors
echo "export TERM=xterm-256color" >> ~/.zshrc

2.3 Install some commonly used software.

yay -S htop
yay -S exa
yay -S duf
yay -S axel 
yay -S the_silver_searcher
yay -S fd
......

enjoy it!

3. reference