Install Windows Subsystem for Linux (WSL2)

These instructions were written while following directions from Microsoft's site: https://learn.microsoft.com/en-us/windows/wsl/install

An Internet connection is required for downloading the Linux distribution.

Installation

Right-click the Windows Start button and select "Windows PowerShell (Admin)".  Confirm the administrator credentials.

Start the installation of "openSUSE Leap 15.5" Linux distribution:
wsl --install openSUSE-Leap-15.5

The installer will first install "Virtual Machine Platform" and "Windows Subsystem for Linux".
Confirm the administrator privilege when prompted.

First time installation

If this is a first time installation, you will see this message:
The requested operation is successful. Changes will not be effective until the system is rebooted.

Save any work and open webpages (such as this one), and then restart the computer.  You can use PowerShell command:
Restart-Computer.

Windows will take a short time to install features before and after restarting.

Log in to Windows.

openSUSE Leap 15.5 installation

A terminal window for Ubuntu Linux installation will begin. 

Press Enter or F10 to continue; this will select "[Next]" at the bottom-right of the screen. 

Press Enter to accept the openSUSE license agreement.

Use Tab to navigate to "Skip User Creation", and press Space to select it.

Press F10 to continue.

Type the password for root user, using Tab to navigate.

Optionally you may authorize a public key that allows passwordless SSH login:
Select Browse and press Enter.
Navigate to the Windows folder (usually under "c") containing an OpenSSH format public key, saved with .pub extenstion.
Select OK and press Enter.

Press F10 to continue.

When the installation is complete, "Configuration Completed" will be displayed.

Press F10 or Enter to finish.

A bash shell for root user is displayed.


Configuration

User account creation

Create the dev group and user:
groupadd dev
useradd --create-home -g dev dev

Set the user password:
passwd dev

Change to the dev user:
su - dev

Install packages

SUSE provides the cnf command to locate packages, and zypper to install them.  For example, default "man" pages are not install.  To install them:
sudo zypper install man-pages-posix

If using a user account, enter the root password when prompted.

To install git:
sudo zypper install git-core

WSL2 System Information

By default, there are no services listening on the Linux system.  You may browse the Linux file system from Windows Explorer under the path \\wsl$\ .  Use this if you need to copy files from your Windows file system.


As part of the "Virtual Machine Platform" installation, additional network adapters were created.  

A "Hyper-V Virtual Ethernet Adapter" was created, named "vEthernet (Default Switch)".   A random IPv4 address is created, in the 172.16.0.0 - 172.31.255.255 range.  It will use a smaller /20 subnet (subnet mask 255.255.240.0).

Another adapter is created for the individual installation, named "vEthernet (WSL)".  It will have a different IPv4 address and subnet, in the 172 space. 

A  172.x.y.1 address at the beginning of the subnet space is used for DNS and Internet routing.  This is part of the WSL installation, and not visible on the Ethernet adapter list.

System time is managed by the virtual machine, not by NTP / chrony.

To open a new terminal, start "openSUSE Leap 15.5" from the Windows Start menu. 

Other Linux Distributions

To shut down the Linux VM from the Linux terminal:
sudo poweroff

To list Linux distributions available from the Microsoft Store:
wsl --list --online

If you don't want to use the Microsoft store, use --install --web-download arguments

If you'd like to remove the Linux distribution, open PowerShell and run "wsl --unregister <Name>"