Configuring .wslconfig and wsl.conf in WSL: A complete practical guide

Last update: 29/10/2025
Author Isaac
  • Understand the scope: .wslconfig is global (WSL 2) and wsl.conf is per distribution.
  • Properly restart WSL (8-second rule) to apply changes.
  • Optimizes resources and I/O: memory, swap, filesystem Linux and DrvFs.
  • Strengthen security and management with Intune, GPO, and appropriate network modes.

Configuring WSL with .wslconfig and wsl.conf

If you're working with Linux within Windows, the key to maximizing performance and stability lies in two configuration files: .wslconfig and wsl.conf . These allow you to adjust everything from how much memory the WSL2 VM uses to how drives are mounted, which DNS servers are used, and whether systemd is enabled on your distribution. Here you'll find a practical and detailed guide to creating environments with WSL2 and Docker , helping you master these options without overcomplicating things.

Before diving in, it's important to understand two things: `.wslconfig` applies global WSL settings (only for WSL 2) , and `wsl.conf` defines the behavior for each distribution . Additionally, there's an unwritten rule: whenever you change something, you must properly restart WSL for the changes to take effect. From here, we'll get down to business with everything you need to know and do, including real-world examples, commands , and best practices.

Key differences between .wslconfig and wsl.conf

There's a very clear distinction between these two files: .wslconfig is global and resides outside of Linux (on Windows), while wsl.conf is local to each Linux distribution and is stored within the Linux system itself. Understanding this will save you a lot of trouble when debugging problems.

In summary: .wslconfig is located in %UserProfile%\\.wslconfig (it doesn't exist by default, you have to create it) and controls the WSL 2 VM (memory, CPU, kernel, networking, etc.). Meanwhile, wsl.conf is located in /etc/wsl.conf within the distribution and governs automounts, internal network options, interoperability with Windows, the default user, boot settings , and more.

Important: The .wslconfig options only affect WSL 2. If you have a distribution running WSL 1, these global options will not apply.

.wslconfig file to configure the WSL 2 virtual machine

The “8-second rule” and how to properly restart WSL

When you change any parameters in .wslconfig or wsl.conf , simply closing the terminal window is not enough . You must wait for the WSL VM to completely shut down, which usually takes about 8 seconds after all sessions are closed.

If you want to force a clean reboot, see the commands to restart WSL and use PowerShell with these commands: wsl --list --running (to check which distros are still active) and wsl --shutdown (to shut them all down). You can also terminate a specific distribution with wsl --terminate <NombreDistro>This step is vital for the changes are applied correctly.

wsl.conf: configuration by distribution (WSL 1 and WSL 2)

The file /etc/wsl.conf It allows you to adjust behavior at the distribution level. It supports INI-type sections: , , , , plus , y In recent systems, it's perfect for deciding how drives are mounted, whether to add the Windows PATH, or which user is used by default.

You can open it with your favorite editor like root: sudo nano /etc/wsl.confIf it doesn't exist, create it. After editing, remember to apply the WSL shutdown rule so that changes take effect.

Enable systemd on your distro

WSL incorporates support for systemd in recent versions (WSL 0.67.6 or higher). If your workflow requires it (for example, services that start via systemd), you can enable it with two lines in wsl.conf:


systemd=true

Check your version with wsl --version and, after editing, run wsl.exe --shutdownTo verify, use systemctl list-unit-files --type=service and you'll see the status of the services. This feature brings WSL closer to a true Linux experience. If you need more in-depth management information, see how manage services with systemd to see practical examples.

Windows Drive Automount (DrvFs)

This section defines how drives like C: or D: are mounted within Linux using DrvFs. You can enable or disable it, change its root, or add permission options.

  • enabled (boolean): By default true, mounts C:/ or D:/ under /mnt.
  • mountFsTab (boolean): by default true, causes WSL to process /etc/fstab at the beginning.
  • root (string): by default /mnt/You can change it to /windir/ and you'll see /windir/c.
  • options: DrvFs-specific comma-separated list (permissions and metadata).

Useful DrvFs options: uid, gid, umask, fmask, dmask, metadata and case. If you activate metadataYou can use masks like umask=022 o dmask=000 and fine-tune permissions as you would in "pure" Linux. If your workflow requires Access Linux partitions from WindowsThis section and DrvFs are key to adjusting permissions and assembly.

  How to Recover Previous Versions of Files in Windows: Complete and Updated Guide

What exactly is DrvFs?

DrvFs is the file system bridge between Windows and Linux in WSL. It allows you to mount Windows drives at /mnt/c , /mnt/d , etc., and define how permissions, case sensitivity, and metadata are handled. If you need more Linux-like behavior, enable metadata and adjust permission masks to your liking.

Network, interoperability, default user, and boot

You can control the hostname, and whether WSL autogenerates it. /etc/hosts y /etc/resolv.confAdjusting this is useful if you prefer to manage DNS manually to achieve more stable or faster resolutions.

This section defines whether you can launch Windows processes from Linux (for example, notepad.exe) and if the Windows PATH is added to $PATHIf you're looking for a more "isolated" Linux environment, disable these options to avoid interference.

Here you choose the default user that the distro boots as. It's best to set it to your normal user account and not root for security reasons, although you can always log in as root occasionally. wsl -u root.

With this you can trigger a command when WSL starts (for example, service docker startand protect the automatic generation of binfmt if you have systemd. It's a practical way to automate services at startup.

GPU and time synchronization

This section lets you decide whether Linux apps can access the Windows GPU via paravirtualization. By default, it's set to enabled=true , which is ideal for AI or graphics workloads.

You can make WSL use and synchronize the Windows time zone with useWindowsTimezone=trueIt's a simple aid for avoid discrepancies and imbalances when changing time zones or putting the computer to sleep. If your goal is to use the GPU for computing, check how Install CUDA on WSL and leaves the drivers and updated toolkits.

Complete example of wsl.conf

This example demonstrates several useful options: changing the mount root , DrvFs permissions, custom DNS , and default user. Note: Remember to restart WSL to see the effects. If you're setting up a development environment, you can follow steps to configure a WSL development environment that integrates these options.

# /etc/wsl.conf

enabled=true
root=/
options="metadata,uid=1003,gid=1003,umask=077,fmask=011,case=off"
mountFsTab=true


hostname=DemoHost
generateHosts=false
generateResolvConf=false


enabled=false
appendWindowsPath=false


default=DemoUser


command=service docker start

.wslconfig: WSL 2 VM global settings

This is where you decide how much memory, CPUs, or swap the VM will have, whether you use a custom kernel, and how the network behaves. Create the file in %UserProfile%\\.wslconfigTo open the folder from PowerShell, use cd ~ or type the path directly into the Explorer with % UserProfile%.

Key parameters in the section:

  • kernel: absolute path in Windows to a custom Linux kernel.
  • kernelModules: VHD with custom kernel modules.
  • memory: RAM limit (default 50% of Windows RAM).
  • processors: logical cores for the WSL 2 VM.
  • localhostForwarding: exposes WSL ports in localhost:puerto of the host.
  • kernelCommandLine: extra kernel parameters (e.g., vsyscall=emulate).
  • safeMode: safe mode to recover problematic distros (Windows 11).
  • swap y swapFile: size and path of the swap disk.
  • pageReporting: automatically returns unused memory to the host.
  • guiApplications- Enables or disables WSLg (Linux GUI apps).
  • debugConsole, maxCrashDumpCount: debugging and dump management.
  • nestedVirtualization: nested on/off virtualization.
  • vmIdleTimeout: milliseconds of inactivity before shutting down the VM.
  • dnsProxy, networkingMode, firewall, dnsTunneling, autoProxyAdvanced network and proxy controls.
  • defaultVhdSize: maximum size of the distro's VHD (e.g., 1 TB).

Formatting notes: entries of type path They must use Windows routes with double backslash, For example: C:\\Temp\\myCustomKernelSizes accept units (MB/GB); if you omit the unit, they are interpreted as bytes. Some options require Windows 11 and recent versions of WSL.

Networking: NAT, mirrored, virtio and more

With networkingMode You choose the network mode: NAT (default), mirrored, virtioproxy, bridged (obsolete) or noneIn NAT, WSL appears behind an internal NAT; in mirrored configuration, the network stack is reflected, simplifying access from the LAN to WSL services; with virtioProxy, an alternative backend is used. If you use mirrored, you can fine-tune with ignoredPorts to allow Linux to bind ports even if Windows uses them.

To expose services on your local network using mirroring, add the following to .wslconfig :


networkingMode=mirrored

Tras wsl --shutdownYou can adjust the Hyper-V firewall using PowerShell (administrator):

New-NetFirewallHyperVRule -DisplayName WSLPrivateInboundRule -Profiles Private -Direction Inbound -Action Allow -VMCreatorId ((Get-NetFirewallHyperVVMCreator).VMCreatorId)
# (Menos seguro) Desactivar la protección de Hyper-V por completo:
# Set-NetFirewallHyperVVMSetting -Name ((Get-NetFirewallHyperVVMCreator).VMCreatorId) -Enabled False

Keep the firewall active on public networks and limit exposure. If you need production capabilities, consider reverse proxying and TLS.

  How to remove and add a printer in Windows 11

experimental setup

This section allows you to activate features in preview. Among others: autoMemoryReclaim (disabled, gradual, dropCache), sparseVhd (scattered VHDs), bestEffortDnsParsing, dnsTunnelingIpAddress, initialAutoProxyTimeout, ignoredPorts y hostAddressLoopbackSome require Windows 11 22H2+ and are intended for optimize memory and network in specific scenarios.

Example of a commented .wslconfig

This example limits resources, uses a custom kernel, adjusts swap space, and enables debugging features. Perfect for standardizing environments on development teams.

# %UserProfile%\\.wslconfig

memory=4GB
processors=2
kernel=C:\\temp\\myCustomKernel
kernelModules=C:\\temp\\modules.vhdx
kernelCommandLine=vsyscall=emulate
swap=8GB
swapFile=C:\\temp\\wsl-swap.vhdx
pageReporting=false
localhostForwarding=true
nestedVirtualization=false
debugConsole=true
maxCrashDumpCount=10


sparseVhd=true

Optimize I/O and memory performance

For intensive work (for example, processing hundreds of 20 MP images (with ODM), it is advisable to adjust global resources and work in the native Linux file system to avoid I/O penalties on /mnt/cSet sufficient memory and swap limits in .wslconfig and check the actual usage with htop o free -h.

Practical recommendations: save your project in /home/Disable auto-mounts if you don't need them, and if the process still runs out of memory, swap increase (e.g., 16 GB) and allocated RAM (e.g., 8–12 GB depending on your machine). If you create .wslconfig If it's the first time and "it doesn't work," make sure it's in % UserProfile%, that the name is literal .wslconfig (without hidden extension) and of Restart WSL completely.

DNS and name resolution

By default, WSL uses the host's DNS servers, but you can choose not to auto-generate them. resolv.conf and put your servers (Cloudflare, Google, corporate) to achieve more predictable resolutions. In /etc/wsl.conf:


generateResolvConf=false

Then create or edit /etc/resolv.conf with the desired entries:

nameserver 1.1.1.1
nameserver 8.8.8.8

If you use modes like dnsProxy or dnsTunneling from .wslconfig , also check their parameters and, if necessary, adjust dnsTunnelingIpAddress or enable bestEffortDnsParsing to resolve requests by ignoring unknown records.

Installation and first steps

WSL comes with Windows, but you have to enable it and install a distroIn modern builds (20262+), simply run from PowerShell or CMD: wsl --installThis command enables the WSL and VM Platform components, downloads the kernel, sets WSL 2 as the default, and installs Ubuntu (may require a reboot).

When you open the distro from Start for the first time, you will be prompted to create Linux username and passwordThey are independent of your Windows account, and that account will be the one that logs in by default. To change the password, use passwdIf you forget it, open the distro as root with wsl -u root o wsl -d <Distro> -u root and run passwd <usuario>.

Update packages and choose where to save your projects

Keep your packages up to date with sudo apt update && sudo apt upgrade (Ubuntu/Debian). And remember this golden rule: Work in the FS where your tools are locatedIf you compile and run using Linux tools, save in \\wsl$\\<Distro>\\home\\<Usuario>If you use Windows tools, keep the files in C:\\Users\\<Usuario>.

To open the current WSL directory in Explorer, run explorer.exe .You can also navigate to routes like \\wsl$\\Debian\\home\\tu-usuario From Windows. If the folder appears empty, open a WSL terminal to activate the VM.

Windows Terminal and code editors

The experience is greatly improved with Windows Terminal (tabs, panels, GPU rendering, themes…). Each installed distro will appear as a configurable profile. For development, the most convenient option is usually… Visual Studio Code with the Remote Development Support (WSL) extension. From the distro, launch code . and you'll have a complete editing environment within WSL.

If you work in C++, Visual Studio 2022 integrates native support for CMake projects targeting WSL or SSH , allowing you to compile and debug on Linux from the same instance of VS.

Git, containers and databases

setup Git in WSL And, if you need it, the credential manager so you don't have to type passwords. Check line endings and files. .gitignore To avoid platform-specific issues, VS Code integrates Git commands that work seamlessly with WSL.

With Docker Desktop and WSL 2, you can easily use containers and, if you wish, connect your project to a remote development container. For databases , WSL seamlessly supports MySQL, PostgreSQL, MongoDB, Redis, SQL Server, and SQLite . It's an ideal environment for cross-platform local development.

GPU acceleration and graphics apps

WSL allows you to take advantage of the GPU of the team For heavy workloads (AI, CUDA, etc.). In practice, just make sure you have up-to-date drivers and toolkits and, if necessary, validate with containers like nvidia/cuda. Also with wslg you can run Linux GUI applications without setting up an external X server.

  How to install or update the Android operating system on a mobile phone from scratch

Useful interoperability commands

There is a very practical coexistence between both worlds. From Windows: wsl ls -la to list with Linux tools and filter with findstr or vice versa (mix dir y grepFrom Linux, launch any Windows app with .exe, for example notepad.exe .bashrc. You also have wslpath to translate routes between systems: wslpath RUTA_WINDOWS o wslpath -w RUTA_LINUX.

Mounting disks and working with external drives

If you need to access a physical disk or memory USB From WSL 2, you can set it up using wsl --mount and manage it as you would in Linux. Remember to check the file system and whether root permissions are required to avoid mounting errors.

Security and administration in the enterprise (Intune and GPO)

You can now manage WSL with tools like Microsoft Intune . From the portal, create a configuration catalog profile and search for "Windows Subsystem for Linux" to see all available options. This is ideal for enforcing policies such as exclusive use of the WSL Store , disabling WSL 1, or preventing custom kernel and network configurations.

Recommended hardening measures for corporate environments: disable AllowInboxWSL (force the Store version), AllowWSL1 , the debug shell , kernel/command-line configuration, custom networking, firewall via .wslconfig, nested virtualization, and kernel debugging. These GPOs are defined using the WSL ADMX file , available on GitHub, and can be imported for local management.

Access control and commands

Policies AllowWSL, AllowInboxWSL y AllowWSL1 They control who can use WSL and which version. You can also allow or block users. wsl --debug-shell y wsl --mount according to your security requirements. It's an additional layer for avoid unwanted configurations in managed teams.

Troubleshooting: Creating .wslconfig and memory cases

If .wslconfig “does nothing”, verify that the file is in %UserProfile%\\.wslconfig, without hidden extension or strange BOM, and that its syntax is valid (section and key=value pairs). After creating or modifying it, run wsl --shutdown and open the distro.

For memory-intensive workloads (such as batches of 470 20MP images ), increase the allocated RAM and swap space. Example starting point:


memory=12GB
processors=8
swap=16GB
swapFile=C:\\WSL\\swap.vhdx
pageReporting=true

Also check that the project is in the Linux FSIf you continue to receive “out of memory” messages, check the tool's own limits (ODM parameters), and activate autoMemoryReclaim If you're interested in quickly recovering cache and monitoring usage, top/ htopDon't forget that Windows also needs sufficient free RAM.

Extra good practices and resources

When experimenting with network mirroring, adjust your firewall settings carefully; if you disable rules for testing, re-enable them afterward. If you need additional documentation or alternative examples, you can explore external resources like this PDF . And if you're working with GPUs, validate your stack (drivers, CUDA/toolkit, versions) before diving in.

For fleet managers, the Intune + ADMX combo provides fine-grained control over what can be modified in .wslconfig, which commands are allowed, and whether WSL 1 distributions are accepted. This helps standardize environments , reduce incidents, and raise the level of security.

With these settings, you have a holistic guide to setting up WSL professionally: use wsl.conf to profile each distro , .wslconfig to govern the global VM , restart WSL wisely, take advantage of Linux's native FS for performance, leverage GPUs and advanced networking, and, if you work in a company, rely on policies to keep everything under control.

How to configure WSL2 with a custom Linux kernel and red-3
Related articles:
How to set up WSL2 with a custom Linux kernel and network
Isaac

Isaac

Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.