WSL Configuration Reference¶
Two config files control WSL2 behavior. They live in different places and serve different purposes.
/etc/wsl.conf (per-distro, inside WSL2)¶
Lives inside each WSL2 distro. Controls distro-specific settings.
[boot]
systemd = true # Enable systemd as PID 1
command = service ssh start # Run as root on distro start
[network]
generateResolvConf = false # Don't auto-generate /etc/resolv.conf
hostname = wsl-dev # Custom hostname (optional)
[automount]
enabled = true # Mount Windows drives under /mnt/
root = /mnt/ # Mount point root
options = "metadata,umask=22,fmask=11" # Default mount options
[interop]
enabled = true # Allow running Windows executables from WSL
appendWindowsPath = true # Append Windows PATH to WSL PATH
Apply changes¶
%UserProfile%\.wslconfig (global, on Windows)¶
Lives at C:\Users\<username>\.wslconfig. Controls the WSL2 VM and all distros.
[wsl2]
memory = 16GB # Max RAM for WSL2 VM (default: 50% of host)
processors = 8 # Max vCPUs (default: all)
swap = 4GB # Swap file size
vmIdleTimeout = -1 # Never auto-shutdown VM (-1 = disabled)
networkingMode = mirrored # Share host network interfaces
dnsTunneling = true # DNS tunneling (mirrored mode)
firewall = true # Apply Windows Firewall to WSL traffic
[general]
instanceIdleTimeout = -1 # Never auto-terminate distro instance
[experimental]
autoMemoryReclaim = disabled # Don't aggressively reclaim WSL memory
sparseVhd = true # Auto-compact virtual disk
Memory Recommendation¶
The RTX 4060 PC likely has 16-32 GB RAM. For ML workloads, give WSL2 a generous allocation. If the host has 32 GB:
This leaves 8 GB for Windows + Tailscale + desktop compositing.
Apply changes¶
Key Interactions¶
| Setting | File | Impact |
|---|---|---|
systemd=true |
wsl.conf | Enables systemctl, services auto-start |
command=... |
wsl.conf | Runs at distro start (as root) |
generateResolvConf=false |
wsl.conf | Prevents DNS file overwrite |
networkingMode=mirrored |
.wslconfig | WSL2 shares host network |
instanceIdleTimeout=-1 |
.wslconfig | Distro stays alive when idle |
vmIdleTimeout=-1 |
.wslconfig | VM stays alive when all distros stop |
memory=... |
.wslconfig | RAM cap for GPU/ML workloads |