Set up Arch Linux in WSL

zstg

zstg

Posted on April 12, 2022

Set up Arch Linux in WSL

Install Arch Linux on WSL

  • Download the latest version of ArchWSL from here
  • NOTE: I've saved the folder as ArchLinux
  • Extract the archive
  • Run the following command in PowerShell to install ArchWSL:
cd D:\
Expand-Archive .\ArchLinux.zip 
D:\ArchLinux\Arch.exe
Enter fullscreen mode Exit fullscreen mode

Screenshot 2022-03-17 145954

Done ! Arch is now installed as a custom distro on WSL.

Init keyring and populate the pacman database

  • Create a new user with sudo privileges
  • Run the following command in PowerShell to boot your distro for the first time:
wsl -d ArchLinux
Enter fullscreen mode Exit fullscreen mode

This should open up a bash terminal, and execute some refreshing-key...-like commands...

echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
Enter fullscreen mode Exit fullscreen mode

This command added in the sudoers file ensures that all the members of the wheel group can execute any command.

pacman -Syy archlinux-keyring
pacman-key --init
pacman-key --populate
pacman -Syy
Enter fullscreen mode Exit fullscreen mode

This will update the pacman database, using the ArchLinux keyring.

Create a new sudo user

READ  -p "Enter the username: " username
useradd -m -g users -G wheel -s /bin/bash $username
passwd $username
su $username
Enter fullscreen mode Exit fullscreen mode

This asks the user the new password as input, and then creates the user with the specified username.

SystemD

curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"
chmod +x install.sh
sudo ./install.sh install
sudo /opt/distrod/bin/distrod enable 
sudo rm ./install.sh
echo ----------------------------------------------------------------------------------------------------------
echo Now terminate this distro and open a new shell!
echo ----------------------------------------------------------------------------------------------------------
Enter fullscreen mode Exit fullscreen mode

curl is a command line tool for transferring files from or to a remote server. It can be used to download files from website links, just like what we have done in the previous step.

chmod is a command line tool for changing the file permissions of files and directories.

echo is a command line tool for printing strings to the standard output.

NOTE: You have to set your user as the default user on ArchLinux.

Do this by running /path/to/arch.exe config --set-default-user <username>.

πŸ’– πŸ’ͺ πŸ™… 🚩
zstg
zstg

Posted on April 12, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related