💾 Archived View for unixcat.coffee › techne › wsl.gmi captured on 2021-12-04 at 18:04:22. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2022-01-08)

-=-=-=-=-=-=-

Windows Subsystem for Linux

Install WSL 2

Run PowerShell as admin and enter the following commands:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Reboot. Then set distro and default WSL version to 2.

wsl --set-version <Distro> 2
wsl --set-default-version 2

Fedora for WSL 2

Download a container image for desired Fedora version:

https://github.com/fedora-cloud/docker-brew-fedora

If we want Fedora 35 for x86_64, append tree/35/x86_64 to the URL above.

Unxz the image, but not untar it.

Create a directory to store the Fedora root filesystem:

mkdir C:\Distros\Fedora-35

Import the root filesystem into WSL 2. The following assumes the unxz'd image is saved in $HOME\Downloads as fedora-35.tar.

wsl.exe --import Fedora-35 c:\Distros\Fedora-35 $HOME\Downloads\fedora-35.tar

On success, Fedora-35 will show up in WSL 2's distribution list.

Now start Fedora-35 as root user:

wsl -d Fedora-35

Update and install essential packages:

printf "fastestmirror=True\ndeltarpm=True\n" | tee -a /etc/dnf/dnf.conf
dnf update -y
dnf install -y wget curl sudo ncurses dnf-plugins-core dnf-utils passwd

Add user:

useradd -G wheel jas
passwd jas

Exit the WSL 2 instance and launch it again, specifying the newly created user, and ensure the UID is 1000:

id -u

Exit the WSL 2 instance.

Set a Windows registry property to set the default user for this Fedora-35 instance:

Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq Fedora-35  | Set-ItemProperty -Name DefaultUid -Value 1000

Enter Fedora-35 and install WSL utilities:

dnf copr enable trustywolf/wslu

~~~

Last updated: 2021-11-19

Back to Techne index

Back to unixcat.coffee