I have being using wsl2 for development for like 4 years i tested arch and other linux but i still find the Ubuntu 24 still more stable for work
here my wsl2 setup to share
https://github.com/karleeov/wslsetup
WSL2 can deliver near-native Linux performance on Windows when configured correctly. This post documents a proven configuration optimized for a workstation with an Intel i9-12900 (16C/24T) and 128GB RAM. It includes the global .wslconfig
, per-distro /etc/wsl.conf
, rationale for each setting, and reproducible setup steps.
Note: Settings are safe defaults for heavy development. Adjust to your hardware and workload.
Hardware profile and targets
- CPU: Intel i9-12900 (16 cores, 24 threads)
- RAM: 128GB
- WSL allocation: 64GB RAM, 20 CPU cores
- Goals: fast builds/containers, stable networking, WSLg apps, GPU access, sane memory reclaim
Global WSL2 config (Windows) — .wslconfig
Place at %UserProfile%\.wslconfig
(for example C:\Users\YOUR_USER\.wslconfig
). Applies to all WSL2 distros.
# WSL2 Global Configuration # Settings apply across all Linux distros running on WSL 2 # Place this file at: %UserProfile%\.wslconfig (C:\Users\li_sz\.wslconfig) [wsl2] # Memory allocation - With 128GB RAM, allocate generous amount for development # Using 64GB (50%) for heavy development workloads memory=64GB # CPU cores - Using 20 of 24 logical processors for optimal performance # Leaving 4 cores for Windows host system processors=20 # Network settings for better connectivity localhostForwarding=true networkingMode=mirrored # DNS and proxy settings for better internet connectivity dnsProxy=true autoProxy=true # Swap configuration for memory management swap=2GB # Enable GUI applications (WSLg) for development tools guiApplications=true # Enable nested virtualization for Docker/containers nestedVirtualization=true # VM idle timeout (60 seconds) to balance performance and resource usage vmIdleTimeout=60000 # Firewall settings for development firewall=true # Enable DNS tunneling for better name resolution dnsTunneling=true # Experimental features for better performance [experimental] # Automatic memory reclaim for better host system performance autoMemoryReclaim=gradual # Sparse VHD for efficient disk usage sparseVhd=true # Better DNS parsing bestEffortDnsParsing=true # Auto proxy timeout for corporate environments initialAutoProxyTimeout=1000
Why these choices:
-
memory=64GB
: ample headroom for compilers, databases, ML, containers; adjust down on smaller hosts. -
processors=20
: reserves 4 logical CPUs for Windows UI/background tasks to keep the host responsive. -
networkingMode=mirrored
+localhostForwarding=true
: simpler, more reliable networking and service access across host/guest. -
dnsProxy
,autoProxy
,dnsTunneling
,bestEffortDnsParsing
: resilient name resolution, especially in corporate networks/VPNs. -
swap=2GB
: prevents abrupt OOM with modest overhead; increase if workloads spike memory. -
guiApplications=true
: WSLg enables Linux GUI apps. -
nestedVirtualization=true
: better Docker/VM-in-WSL scenarios. -
vmIdleTimeout=60000
: power/perf balance; increase if WSL shuts down too eagerly during pauses. -
[experimental].autoMemoryReclaim=gradual
: returns idle memory to Windows over time. -
sparseVhd=true
: reduces VHD growth; compacts better over time. -
firewall=true
: routes through Windows Firewall for consistent policy.
Per-distro config (Linux) — /etc/wsl.conf
Copy this into each distro at /etc/wsl.conf
. Tailor the [user]
section to your username.
# Sample wsl.conf - Copy this to /etc/wsl.conf in your WSL distributions # This file configures per-distribution settings [boot] # Enable systemd for modern Linux distributions (Ubuntu, Arch, etc.) systemd=true # Optional: Run commands on boot (uncomment and modify as needed) # Examples: # command="service docker start" # command="service ssh start && service nginx start" [automount] # Enable automatic mounting of Windows drives enabled=true # Mount Windows drives under /mnt (default) or change to your preference root=/mnt # Set proper permissions and metadata support # uid=1000,gid=1000 should match your Linux user ID options="metadata,uid=1000,gid=1000,umask=0022,fmask=0111,case=off" # Process /etc/fstab for additional mounts mountFsTab=true [network] # Generate /etc/hosts automatically generateHosts=true # Generate /etc/resolv.conf automatically generateResolvConf=true # Set hostname (optional - uncomment to customize) # hostname=dev-machine [interop] # Enable Windows/Linux interoperability enabled=true # Add Windows PATH to Linux PATH appendWindowsPath=true [user] # Set default user (replace with your actual username) # Find your username with: whoami # default=yourusername [gpu] # Enable GPU access for development and ML workloads enabled=true [time] # Sync timezone with Windows useWindowsTimezone=true
Key notes:
-
systemd=true
: enables modern service management (systemctl
). -
[automount]
withmetadata
anduid/gid
: correct permissions on/mnt/c/...
. -
mountFsTab=true
: honors custom mounts via/etc/fstab
. -
appendWindowsPath=true
: convenient access to Windows tools from Linux. -
[gpu].enabled=true
: unlocks CUDA/DirectML where supported. -
[user]
: setdefault=
to your Linux username to avoid root logins.
Setup — automated or manual
Automated (recommended):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser .\setup.ps1
Manual:
1) Apply global config
Copy-Item "C:\Users\li_sz\wslsetup\.wslconfig" "$env:USERPROFILE\.wslconfig" -Force wsl --shutdown Start-Sleep -Seconds 8
2) Configure each distro
# Example for Ubuntu; repeat for Arch/Kali/NixOS by changing the name wsl -d Ubuntu-24.04 sudo cp /mnt/c/Users/li_sz/wslsetup/wsl.conf /etc/wsl.conf sudo nano /etc/wsl.conf # set [user].default to your username
3) Final restart
wsl --shutdown Start-Sleep -Seconds 8
Verify
free -h # memory accounting nproc # CPU cores available lscpu # CPU details df -h # disk space systemctl status # systemd active? ls -la /mnt/ # windows drives ip addr show # interfaces ping google.com # outbound connectivity nvidia-smi # GPU (if NVIDIA)
Windows-side diagnostics:
wsl --status wsl --list --verbose wsl --version please comment if you have idea how to develop better on wsl2 working environment
Expected results
- Build times: significant improvements vs default WSL2 (fewer stalls under load).
- Memory behavior: stable under large compiles/containers; unused memory gradually returned to Windows.
- Networking: mirror mode produces fewer surprises on VPNs and corporate Wi-Fi.
- File I/O: consistent experience accessing Windows paths via
/mnt
.
Troubleshooting
- WSL won’t start: confirm
wsl --version
and Windows features are enabled. - Memory limits ignored: ensure
.wslconfig
resides in your user profile, thenwsl --shutdown
. - DNS/Network: restart WSL and verify
generateResolvConf=true
; watch for VPN DNS overrides. - Permissions under
/mnt
: confirmoptions="metadata,uid=1000,gid=1000,..."
and your UID/GID.
Tips
- Use Arch for cutting-edge dev, Ubuntu 24.04 for stability, Kali for security work, NixOS for reproducibility.
- Monitor with
htop
,iotop
, and Windows Task Manager to fine-tunememory
/processors
. - For container-heavy work, consider increasing
swap
to 4–8GB if builds occasionally OOM.
This configuration balances raw performance with host stability and is a solid baseline for demanding daily development on Windows 11 with WSL2.
Top comments (0)