WSL info
- Comparing WSL 1 and WSL 2
- WSL 2 Settings
- Configure per distro launch settings with wslconf
- wslu - A collection of utilities for WSL
- Pengwin - NONFREE!!! Linux distribution optimized for WSL
- WSL-Programs - A community powered list of programs that work
- Bash On Ubuntu On Windows
Trouble
Install
- Enable the Windows Subsystem for Linux (Powershell as admin):
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - Enable Virtual Machine feature (Powershell as admin):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart -
Restart your machine to complete the WSL install.
-
Download the Linux kernel update package: https://aka.ms/wsl2kernel (direct download).
- Set WSL 2 as your default version (as admin):
wsl --set-default-version 2 - Goto Windows store and install your favorite (Debian) distro. (Direct download here.)
More info:
- https://aka.ms/wsl2
Upgrade Linux kernel
Suprise, surprise. This doesn’t happen automatically.
-
Download the Linux kernel update package: https://aka.ms/wsl2kernel (direct download).
-
Restart your machine, and your WSL should be running the new kernel version.
X Server and UI apps from WSL2
This is just a shit show! But here goes… (Info on VSOCK and WSL2)
Main guide: Using IntelliJ with Windows Subsystem for Linux 2.
Run the X Server with Cygwin/X
-
Install XWin stuff with Cygwin/X as described here!
-
Run this command:
C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- -ac -multiwindow -wgl -clipboard -noprimary -listen tcp"
Allow Inbound connections to C:\cygwin64\bin\xwin.exe in the Windows Firewall
- Launch the above command, and the first time it will ask for Firewall permissions. Only allow
Private networks. - This will create block rules on
Public networkswhich needs to be removed or disabled. - Create a new firewall rule:
- Right click on
Inbound Rules - Choose
New Rule... - Leave it at
Programand chooseNext > - Set
This program pathtoC:\cygwin64\bin\xwin.exe - Leave it at
Allow the connectionand clickNext > - Only
Publicshould be chosen and clickNext >. - Add a
Namefx.xwin (WSL2)and clickFinish. - Open the newly created rule and go to
Scope. - Change
Remote IP addresstoThese IP addresses:. - Click
Add.... - Input all reserved private IPv4 network ranges. Yes it sucks! But WSL moves around from reboot to reboot!
- Right click on
Local IP ranges:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
WSL Windows Toolbar Launcher has a good guide on the Firewall rules.
Set the DISPLAY ENV variable in Wsl2, preferably in the ~/.bashrc file
export WSL_HOST=$(grep ^nameserver /etc/resolv.conf | cut -d' ' -f2)
export DISPLAY=${WSL_HOST}:0.0
Vmmem using all memory and CPU?
We need to set some reasonable resource constraints on what WSL2 can actually use. Fortunately, that’s as simple as going to c:\users\*your your profile name* and creating a .wslconfig file. On my setup, a MSI Prestige 15 with a 10710u 6-core processor and 16GB of RAM, mine looks like this:
[wsl2]
memory=4GB # Limits VM memory in WSL 2 to 4 GB
processors=5 # Makes the WSL 2 VM use two virtual processors
And then, from Powershell with admin rights, restart WSL2 by typing:
Restart-Service LxssManager
Launching Docker Desktop WSL2
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Debian Stopped 2
docker-desktop-data Stopped 2
docker-desktop Stopped 2
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Debian Stopped 2
docker-desktop-data Stopped 2
docker-desktop Running 2
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Debian Stopped 2
docker-desktop-data Running 2
docker-desktop Running 2
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Debian Stopped 2
docker-desktop-data Running 2
docker-desktop Running 2
PS C:\WINDOWS\system32> wsl -l -v
NAME STATE VERSION
* Debian Running 2
docker-desktop-data Running 2
docker-desktop Running 2