Mr. Editor-in-chief Mr. Editor-in-chief November 8, 2024 Updated April 24, 2026

WSL Basics

Install WSL

  • wsl -l -o # Open Powershell & get a list of available Linux distributions available for download
  • wsl --install -d Ubuntu-22.04
  • If Error: 0x800706d9 There are no more endpoints available from the endpoint mapper, Services -> Host Network Service -> Start, and rerun the command wsl --install -d Ubuntu-22.04

Uninstall && Remove WSL

  • Settings -> Apps -> Installed apps -> Ubuntu -> Uninstall
  • wsl -l -v # Open Powershell & Get WSL version
  • wsl --unregister Ubuntu

Keeping WSL Running in the Background (even after closing the terminal window)

  • wsl --exec dbus-launch true in powershell

Accessing a WSL service from a remote machine (Mirror a WSL ip address and port to that of the host)

  • wsl hostname -I # Get WSL local IP address (CMD or Powershell)
  • netsh interface portproxy add v4tov4 listenport=11434 listenaddress=0.0.0.0 connectport=11434 connectaddress=172.19.98.153 # Run in CMD as administrator
  • Open the port in Inbound Rules in Windows Defender Firewall with Advanced Security on Local Computer

How to Shrink a WSL2 Virtual Disk

  • wsl --shutdown # Open Powershell and shutdown the running WSL distributions
  • diskpart
DISKPART> select vdisk file="C:\Users\penl\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc\LocalState\ext4.vhdx"

DiskPart successfully selected the virtual disk file.
DISKPART> compact vdisk

  100 percent completed

DiskPart successfully compacted the virtual disk file.