Cookie Consent by Free Privacy Policy Generator 📌 Install Arch Linux in WSL2 on a managed device


✅ Install Arch Linux in WSL2 on a managed device


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Acquiring the image

First, you need to download and install a bootstrapped Arch Linux image.

Open a Windows PowerShell and download a bootstrapped tarball from a suitable Arch Linux mirror:

Invoke-WebRequest -Uri "https://archlinux.mirror.pcextreme.nl/iso/latest/archlinux-bootstrap-x86_64.tar.gz" -OutFile "$HOME\Downloads\archlinux-bootstrap-x86_64.tar.gz"

Extract and repackage the bootstrap image

Extract and repackage the downloaded bootstrap image in another Linux distro, e.g. WSL Ubuntu.

# Go to the user's Downloads folder
cd /mnt/c/Users/$USER/Downloads/

# Move the downloaded file to the Linux home folder
mv archlinux-bootstrap-x86_64.tar.gz ~

# Go to your home folder
cd

# Extract the tar.gz bootstap file
tar -zxvf archlinux-bootstrap-x86_64.tar.gz

# Go to the following subdirectory
cd root.x86_64

# Repackage the extracted tar.gz (there is a dot at the end)
tar -zcvf archlinux-bootstrap_repackage-x86_64.tar.gz .

# Put the file back to your Windows Downloads folder
mv archlinux-bootstrap_repackage-x86_64.tar.gz /mnt/c/Users/$USER/Downloads/

Pick an installation location

Create a directory in you home folder labeled “wsl”. Make sure that each distro has their own location.

md "$HOME\Linux Distros\ArchLinux"

Import the tarball and update the system

Import the tarball requires an installation location with no other distro, or otherwise it will fail.

wsl --import Arch "$HOME\Linux Distros\ArchLinux" "$HOME\Downloads\archlinux-bootstrap_repackage-x86_64.tar.gz"

When importing the tarball is complete, run

wsl -d Arch

You will be greeted with a root user prompt #.

Switch to the home directory with cd.

Enable DNS resolving

Now you will need a working internet connection. In my case, DNS was not resolving from within WSL. If that's the case for you as well do the following:

cat > /etc/wsl.conf<< EOF
[network]
generateResolvConf = false
EOF

And use Google's DNS:

cat > /etc/resolv.conf<< EOF
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF

Make pacman work

sed -i 's:#Server:Server:g' /etc/pacman.d/mirrorlist

Initialize the keyring and populate it

pacman-key --init && pacman-key --populate archlinux

Update packages

Let's update the system first now that we should have a working network:

pacman -Syu

Use reflector to find the fastest mirrors

# First install reflector
pacman -Sy reflector

# Then use reflector to find the fastest mirror for your location ("Netherlands" in my case).
reflector --country "Netherlands" --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

Installing some required packages

pacman -Sy base-devel git vim nano wget sudo which go openssh man-db bash-completion fontconfig ntp

Setting up passwords and one user with sudo privileges

export EDITOR=vim; visudo

Uncomment the line containing %wheel ALL=(ALL) ALL; do the same to the next line with %wheel if you want to run sudo tasks without having to provide your password.

root password

Set the root user password with passwd before setting up the login user account.

passwd

Creating a user and setting a password

Now create a user and set a password.

useradd -m -G wheel -s /bin/bash -d /home/rubenjs rubenjs; passwd rubenjs

Setting up wsl.conf

Because Arch Linux was imported, by default the login user is the root user even with a user account. To prevent this, a config file needs to be created to tell wsl which user to log in. Create the file /etc/wsl.conf and copy the following, replacing ‘rubenjs’ with your own username.

Settings for wsl.conf

[automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=22,fmask=11,case=off"
mountFsTab = true
crossDistro = true

[network]
generateHosts = true # When using with systemd, otherwise `false`.
generateResolvConf = true

[interop]
enabled = true
appendWindowsPath = true

[user]
default = rubenjs

[boot]
systemd=true

Finishing the setup process

If you use Windows Terminal, the best way is to close it, and then reopen it. A new profile for Arch has been added.

Check if systemd is working

sudo systemctl status

If systemd is functional, you should see a green indication, and you can create your own systemctl scripts, but before that, let’s first enable some services.

sudo systemctl enable --now dbus.service ntpd.service sshd.service

Installing and aur helper such as yay

git clone https://aur.archlinux.org/yay-bin
cd yay-bin
makepkg -si --noconfirm

Adjust locale

sudo vim /etc/locale.gen

Uncomment the locales you use on your instance. For me, I uncomment nl_NL.UTF-8 UTF-8 and en_US.UTF-8 UTF-8.

Then generate the locales

sudo locale-gen

sudo su

echo "LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE=nl_NL.UTF-8
LC_NUMERIC=nl_NL.UTF-8
LC_TIME=nl_NL.UTF-8
LC_COLLATE=nl_NL.UTF-8
LC_MONETARY=nl_NL.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=nl_NL.UTF-8
LC_NAME=nl_NL.UTF-8
LC_ADDRESS=nl_NL.UTF-8
LC_TELEPHONE=nl_NL.UTF-8
LC_MEASUREMENT=nl_NL.UTF-8
LC_IDENTIFICATION=nl_NL.UTF-8
LC_ALL=
" > /etc/locale.conf
Optional: Enabling multilib
linenumber=$(grep -nr "\\#\\[multilib\\]" /etc/pacman.conf | gawk '{print $1}' FS=":")
sed -i "${linenumber}s:.*:[multilib]:" /etc/pacman.conf
linenumber=$((linenumber+1))
sed -i "${linenumber}s:.*:Include = /etc/pacman.d/mirrorlist:" /etc/pacman.conf
...

✅ Install Arch Linux in WSL2 on a managed device


📈 52.55 Punkte

✅ Arch Anywhere ISO Lets You Install a Fully Custom Arch Linux System in Minutes


📈 29.03 Punkte

✅ Arch Anywhere ISO Lets You Install a Fully Custom Arch Linux System in Minutes


📈 29.03 Punkte

✅ Arch Conf 2020 - Enter the Matrix: Install your own Matrix server on Arch Linux


📈 29.03 Punkte

✅ easy-arch (a fashionable way to install Arch Linux)


📈 29.03 Punkte

✅ Finally managed to install Arch Linux! its so good!


📈 28.08 Punkte

✅ I have 0 background in tech, 0 understanding of Linux yet managed to install Arch, you’re not special.


📈 28.08 Punkte

✅ Can I install Gentoo inside Arch with my /boot partition in the Arch partition


📈 26.78 Punkte

✅ Expo AVD (Android Virtual Device) on Windows Subsystem for Linux (WSL2)


📈 26.72 Punkte

✅ Is it possible to install Linux on an unformated drive position with WSL2 ?


📈 25.69 Punkte

✅ WSL2 Lets You Install the Linux Kernel as a Windows Update


📈 25.69 Punkte

✅ How to install WSL2 on Windows 10: – A Linux User’s Guide


📈 25.69 Punkte

✅ How to install WSL2 on Windows 10: – A Linux User’s Guide


📈 25.69 Punkte

✅ How to install Linux WSL2 on Windows 10 and Windows 11


📈 25.69 Punkte

✅ Arch Linux Officially Kills 32-Bit Support, Migrate to "Arch Linux 32" Fork Now


📈 25.14 Punkte

✅ How to (Finally) Install TensorFlow GPU on WSL2


📈 23.45 Punkte

✅ Install WSL2 🐧 on Windows 11


📈 23.45 Punkte

✅ Install zsh-autocomplete on WSL2


📈 23.45 Punkte

✅ Questions about Arch Linux and the Arch User Repository (AUR)


📈 22.89 Punkte

✅ TIL That Arch Linux has retro websites of Arch in URL form : https://www.archlinux.org/retro/2002/


📈 22.89 Punkte

✅ [1920x1080] Arch Linux wallpaper that I made for my Arch computer


📈 22.89 Punkte

✅ Arch Conf 2020: Die Linux-Distribution Arch skizziert ihre Zukunft


📈 22.89 Punkte

✅ Arch Conf 2020 - Closing Talk: Arch Linux Conf in review


📈 22.89 Punkte

✅ Arch Conf 2020 - GamerOS: An Arch Linux based gaming OS


📈 22.89 Punkte

✅ Arch Conf 2020 - Arch Linux Team Q&A


📈 22.89 Punkte

✅ Arch Conf 2020 - Packaging Rust Applications for Arch Linux


📈 22.89 Punkte

✅ Arch Conf 2020 - Arch Linux: Past, Present and Future


📈 22.89 Punkte

✅ Arch Linux software projects: Request for participation - Arch-dev-public


📈 22.89 Punkte

✅ Useless fact about Arch Linux (and Arch based distros):


📈 22.89 Punkte











matomo

Datei nicht gefunden!