Install WSL with a single command now available in Windows 10 version 2004 and higher
With Windows 10 "2004" [20H1] (Build: 19041), it's no longer necessary to manually install WSL. To install, simply execute in shell:
wsl.exe --install
-
Add the following Windows features:
- Windows Subsystem for Linux (WSL required)
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Virtual Machine Platform (WSL2)
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
-
Windows needs to be rebooted.
shutdown /r /t 10 /c "WSL Setup" /d p:2:4
-
Install Linux Kernel update package
cd %PUBLIC%\Downloads
wget "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
wsl_update_x64.msi /passive /q /forcerestart
-
Set WSL 2 as default
wsl --set-default-version 2
-
Install Linux distro's from Microsoft Store
wsl --list --online
# Doesn't workRequires Chocolatey to be installed!
choco install wsl-alpine /y choco install wsl-ubuntu-2004 /y choco install wsl-archlinux /y choco install wsl-fedoraremix /y choco install wsl-debiangnulinux /y choco install wsl-kalilinux /y choco install wsl-opensuse /y choco wsl-kalilinux wsl-opensuse /y
Install multiple at once:
choco install wsl-alpine wsl-ubuntu-2004 wsl-archlinux wsl-fedoraremix wsl-debiangnulinux /y
-
Set username and password for distro
-
Update distribution with package manager
[Debian Lineage]
apt update
apt upgrade
[RHEL Lineage]
dnf upgrade --refresh
[Alpine Lineage]
apk update
apk upgrade
-
all files by default are located in the user profile:
C:\Users\<user>\AppData\Local\Packages
-
main file is a virtual harddisk: ext4.vhdx
-
Change location for a distro
[EXPORT]
wsl.exe --export <Distro> <FileName>
[IMPORT]
wsl.exe --import <Distro> <InstallLocation> <FileName> [Options]
-
To access wsl linux distro file system from Windows
\\wsl$\<distroName>
-
LAN Networking (port proxy)
netsh interface portproxy add v4tov4 listenport=<port#> listenaddress=0.0.0.0 connectport=<port#> connectaddress=<VM IP Address>
e.g.
netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 connectport=4000 connectaddress=192.168.101.100
-
Default storage capacity is up to 256 GB
To expand, follow the following instructions.
- Cross file system is slow, i.e. linux internally using windows files.
- no pre-built CENTOS distro
- no IPv6 support