Skip to content

Instantly share code, notes, and snippets.

@mal1kc
Last active September 27, 2022 11:37
Show Gist options
  • Save mal1kc/57aa520b18cdd4be9a3ede0acc312f6b to your computer and use it in GitHub Desktop.
Save mal1kc/57aa520b18cdd4be9a3ede0acc312f6b to your computer and use it in GitHub Desktop.
install archlinux to wsl 2

install archlinux to wsl 2

  1. install archlinux-bootsrap-<version>-x86_64.tar.gz from one of the mirrors file and verify its signature
  2. import using
   wsl --import <distro name> <install location> <location of archlinux-bootstrap.tar.gz file>
   # example
   wsl --import arch "d:\wslDistroStorage\arch" "d:\wslD*\archlinux-bootstarp.tar.gz"
  1. open arch in wsl and set things up

    wsl -d arch
    
    # set up pacman's keys
    pacman-key --init
    pacman-key --populate archlinux
    
    # if command above fails ,run this
    # rm -rf /etc/pacman.d/gnupg

    archwiki link > set up pacman's mirros list (change country code to your country's code or some close countries's code,last in URL param)

    curl -s "https://archlinux.org/mirrorlist/?protocol=https&ip_version=4&use_mirror_status=on&country=DE&country=TR" sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -
    
    # update system and install important packages
    
    pacman -Syu
    pacman -S --needed base-devel
    pacman -S pacman-contrib micro neovim fish
    
    #set root password
    passwd
    
    # set your language.
    micro /etc/locale.gen # for english uncomment 'en_US.UTF-8 UTF-8' and save with ctrl+s
    locale-gen
    echo 'LANG=en_US.UTF-8' >> /etc/locale.conf
    
    # set up sudoers by uncommenting '%wheel ALL=(ALL:ALL) ALL'
    micro /etc/sudoers
    
    # create user (replace yourname with mal1kc)
    useradd -m -G wheel mal1kc # -m for create /home/mal1kc dir -G for add to wheel group
    
    # change password of user
    passwd mal1kc
    
    # set default user for wsl
    echo -e "[user]\ndefault = mal1kc" >> /etc/wsl.conf
    
    # if you want you can set custom hostname
    echo -e "[network]\nhostname = arch" >> /etc/wsl.conf
    
    # change user's shell to fish for better workflow
    
    which fish # get fish binary location
    
    chsh mal1kc -s/usr/bin/fish
    
    # we write fish location it is probably usr/sbin/fish or /bin/fish
    
    # install additional packages for your prefered packages
    
    pacman -S bat dust emacs fd fzf gcc git the_silver_searcher lsd ncdu nnn ripgrep reflector 
    
  2. we can now start using arch with WSL2

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