Skip to content

Instantly share code, notes, and snippets.

@Purpzie
Last active June 19, 2023 19:37
Show Gist options
  • Save Purpzie/743f03d3527d9b20eadecd68f0144fa9 to your computer and use it in GitHub Desktop.
Save Purpzie/743f03d3527d9b20eadecd68f0144fa9 to your computer and use it in GitHub Desktop.
Arch WSL setup guide
  1. Download archlinux-bootstrap-<version>-x86_64.tar.gz from one of the mirrors. You should verify its signature.

  2. While it's possible to import a .tar.gz into WSL, Arch's bootstrap needs to be adjusted first. Open any Linux distro that can transfer files to/from Windows. (WSL counts.)

  3. In Linux:

    # This needs to be done as root to avoid WSL permission issues.
    sudo -i
    
    # Extract it, cd into the folder, and compress it again.
    tar -zxvf archlinux-bootstrap-<version>-x86_64.tar.gz
    cd root.x86_64
    tar -zcvf ../archbootstrap.tar.gz .
    
    # Move it to Windows somewhere.
    mv ../archbootstrap.tar.gz /mnt/c/Users/purpzie/archbootstrap.tar.gz
  4. In Windows:

    :: wsl --import <distro name> <where to store the distro> <path to the .tar.gz>
    wsl --import Arch "C:\Users\purpzie\arch" "C:\Users\purpzie\archbootstrap.tar.gz"
    wsl -d Arch
    echo -e '[boot]\nsystemd = true' >> /etc/wsl.conf
    exit
    wsl --shutdown
    wsl -d Arch

Congrats, you're in Arch Linux. Here's how to get it working:

# Set up pacman's keys.
pacman-key --init
pacman-key --populate archlinux
# If the above command fails, run this and try again:
# rm -rf /etc/pacman.d/gnupg

# Set up pacman's mirror list. (If you're not in the US, change the last URL param.)
curl -s "https://archlinux.org/mirrorlist/?protocol=https&ip_version=4&use_mirror_status=on&country=US" | sed -e 's/^#Server/Server/' -e '/^#/d' > /etc/pacman.d/mirrorlist

# Update the system and install important packages.
pacman -Syu
pacman -S --needed base-devel
pacman -S nano pacman-contrib

# Set your language.
nano /etc/locale.gen # For english, uncomment 'en_US.UTF-8 UTF-8' and save.
locale-gen
echo 'LANG=en_US.UTF-8' >> /etc/locale.conf

# Set a root password.
passwd

# Set up sudoers by uncommenting '%wheel ALL=(ALL:ALL) ALL'
EDITOR=nano visudo

# Create a user and set them as the default. (Replace purpzie with your username.)
useradd -m -G wheel purpzie
passwd purpzie
echo -e '[user]\ndefault = purpzie' >> /etc/wsl.conf

# If you want, you can set a custom hostname too.
echo -e '[network]\nhostname = arch' >> /etc/wsl.conf

Go back to windows, use wsl --shutdown, then open a new Arch shell. You should be good to go!

@bubnenkoff
Copy link

@Purpzie

PS C:\Users\Dima> wsl -d Arch
Processing fstab with mount -a failed.

<3>WSL (8) ERROR: CreateProcessEntryCommon:358: getpwuid(0) failed 2
<3>WSL (8) ERROR: CreateProcessEntryCommon:362: getpwuid(0) failed 2
<3>WSL (8) ERROR: CreateProcessEntryCommon:570: execvpe /bin/sh failed 2
<3>WSL (8) ERROR: CreateProcessEntryCommon:579: Create process not expected to return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment