## Create .wslconfig in C:/Users/youruser
[wsl2]
memory=3GB # Limits VM memory in WSL 2 up to 3GB
processors=4 # Makes the WSL 2 VM use four virtual processors
wsl --set-version <distro_name> <version>
wsl --set-version Ubuntu-18.04 2
wsl --set-version Ubuntu-20.04 2
wsl --install
Enable Windows Subsystem for linux: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable Virtual Machine Platform: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Download WSL2 kernel: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Set default WSL verison: wsl --set-default-version 2
wsl --set-version <distro_name> <version>
wsl --set-version Ubuntu-18.04 2
wsl --set-version Ubuntu-20.04 2
wsl --set-version <distro_name> <version>
wsl --set-version Ubuntu-18.04 2
wsl --set-version Ubuntu-20.04 2
[wsl2]
# https://docs.microsoft.com/en-us/windows/wsl/wsl-config (Docs)
# https://github.com/microsoft/WSL/issues/4166 (Topic)
memory=4GB
swap=16GB
localhostForwarding=true
# turn off all wsl instances such as docker-desktop
wsl --shutdown
notepad "$env:USERPROFILE/.wslconfig"
# .wslconfig
[wsl2]
memory=3GB # Limits VM memory in WSL 2 up to 3GB
processors=4 # Makes the WSL 2 VM use two virtual processors
Stored in your %UserProfile% directory.
Used to configure settings globally across all installed Linux distributions running as the WSL 2 version.
Can be used only for distributions run by WSL 2. Distributions running as WSL 1 will not be affected by this configuration as they are not running as a virtual machine.
To get to your %UserProfile% directory, in PowerShell, use cd ~ to access your home directory (which is typically your user profile, C:Users<UserName>) or you can open Windows File Explorer and enter %UserProfile% in the address bar. The directory path should look something like: C:Users<UserName>.wslconfig.