You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: WSL/wsl-config.md
+29-31Lines changed: 29 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,8 @@
1
1
---
2
2
title: Advanced settings configuration in WSL
3
3
description: A guide to the wsl.conf and .wslconfig files used for configuring settings when running multiple Linux distributions on Windows Subsystem for Linux.
4
-
ms.date: 12/16/2024
4
+
ms.date: 05/19/2025
5
5
ms.topic: article
6
-
ms.custom: seo-windows-dev
7
-
adobe-target: true
8
6
---
9
7
10
8
# Advanced settings configuration in WSL
@@ -62,12 +60,12 @@ You will then need to close your WSL distribution using `wsl.exe --shutdown` fro
62
60
63
61
wsl.conf section label: `[automount]`
64
62
65
-
|key|value|default|notes|
63
+
|Key|Value|Default|Notes|
66
64
|:-----------|:---------|:--------|:------|
67
-
|`enabled`| boolean |`true`|`true` causes fixed drives (i.e `C:/` or `D:/`) to be automatically mounted with DrvFs under `/mnt`. `false` means drives won't be mounted automatically, but you could still mount them manually or via `fstab`. |
68
-
|`mountFsTab`| boolean |`true`|`true` sets `/etc/fstab` to be processed on WSL start. /etc/fstab is a file where you can declare other filesystems, like an SMB share. Thus, you can mount these filesystems automatically in WSL on start up. |
69
-
|`root`| string |`/mnt/`| Sets the directory where fixed drives will be automatically mounted. By default this is set to `/mnt/`, so your Windows file system C-drive is mounted to `/mnt/c/`. If you change `/mnt/` to `/windir/`, you should expect to see your fixed C-drive mounted to `/windir/c`.|
70
-
|`options`| comma-separated list of values, such as uid, gid, etc, see automount options below |empty string | The automount option values are listed below and are appended to the default DrvFs mount options string. **Only DrvFs-specific options can be specified.**|
65
+
|`enabled`| boolean |`true`|`true` causes fixed drives (i.e `C:/` or `D:/`) to be automatically mounted with DrvFs under `/mnt`. `false` means drives won't be mounted automatically, but you could still mount them manually or via `fstab`. |
66
+
|`mountFsTab`| boolean |`true`|`true` sets `/etc/fstab` to be processed on WSL start. /etc/fstab is a file where you can declare other filesystems, like an SMB share. Thus, you can mount these filesystems automatically in WSL on start up. |
67
+
|`root`| string |`/mnt/`| Sets the directory where fixed drives will be automatically mounted. By default this is set to `/mnt/`, so your Windows file system C-drive is mounted to `/mnt/c/`. If you change `/mnt/` to `/windir/`, you should expect to see your fixed C-drive mounted to `/windir/c`.|
68
+
|`options`| comma-separated list of values, such as uid, gid, etc, see automount options below |`""`| The automount option values are listed below and are appended to the default DrvFs mount options string. **Only DrvFs-specific options can be specified.**|
71
69
72
70
The automount options are applied as the mount options for all automatically mounted drives. To change the options for a specific drive only, use the `/etc/fstab` file instead. Options that the mount binary would normally parse into a flag are not supported. If you want to explicitly specify those options, you must include every drive for which you want to do so in `/etc/fstab`.
73
71
@@ -77,17 +75,17 @@ Setting different mount options for Windows drives (DrvFs) can control how file
77
75
78
76
| Key | Description | Default |
79
77
|:----|:----|:----|
80
-
| `uid` | The User ID used for the owner of all files | The default User ID of your WSL distro (on first installation this defaults to 1000)
81
-
| `gid` | The Group ID used for the owner of all files | The default group ID of your WSL distro (on first installation this defaults to 1000)
82
-
| `umask` | An octal mask of permissions to exclude for all files and directories | `022`
83
-
| `fmask` | An octal mask of permissions to exclude for all files | `000`
84
-
| `dmask` | An octal mask of permissions to exclude for all directories | `000`
85
-
| `metadata` | Whether metadata is added to Windows files to support Linux system permissions | `disabled`
86
-
| `case` | Determines directories treated as case sensitive and whether new directories created with WSL will have the flag set. See [case sensitivity](./case-sensitivity.md) for a detailed explanation of the options. Options include `off`, `dir`, or `force`. | `off`
78
+
|`uid`| The User ID used for the owner of all files | The default User ID of your WSL distro (on first installation this defaults to 1000)|
79
+
|`gid`| The Group ID used for the owner of all files | The default group ID of your WSL distro (on first installation this defaults to 1000)|
80
+
|`umask`| An octal mask of permissions to exclude for all files and directories |`022`|
81
+
|`fmask`| An octal mask of permissions to exclude for all files |`000`|
82
+
|`dmask`| An octal mask of permissions to exclude for all directories |`000`|
83
+
|`metadata`| Whether metadata is added to Windows files to support Linux system permissions |`disabled`|
84
+
|`case`| Determines directories treated as case sensitive and whether new directories created with WSL will have the flag set. See [case sensitivity](./case-sensitivity.md) for a detailed explanation of the options. Options include `off`, `dir`, or `force`. |`off`|
87
85
88
86
By default, WSL sets the uid and gid to the value of the default user. For example, in Ubuntu, the default user is uid=1000, gid=1000. If this value is used to specify a different gid or uid option, the default user value will be overwritten. Otherwise, the default value will always be appended.
89
87
90
-
User file-creation mode mask (umask) sets permission for newly created files. The default is 022, only you can write data but anyone can read data. Values can be changed to reflect different permission settings. For example, `umask=077` changes permission to be completely private, no other user can read or write data. To further specify permission, fmask (files) and dmask (directories) can also be used.
88
+
The above umask, fmask, etc. options will only apply when the Windows drive is mounted with metadata. By default metadata is not enabled. You can [find more info about this here](./file-permissions).
91
89
92
90
> [!NOTE]
93
91
> The permission masks are put through a logical OR operation before being applied to files or directories.
@@ -100,7 +98,7 @@ DrvFs is a filesystem plugin to WSL that was designed to support interop between
100
98
101
99
wsl.conf section label: `[network]`
102
100
103
-
|key|value|default|notes|
101
+
|Key|Value|Default|Notes |
104
102
|:----|:----|:----|:----|
105
103
|`generateHosts`| boolean |`true`|`true` sets WSL to generate `/etc/hosts`. The `hosts` file contains a static map of hostnames corresponding IP address. |
106
104
|`generateResolvConf`| boolean |`true`|`true` sets WSL to generate `/etc/resolv.conf`. The `resolv.conf` contains a DNS list that are capable of resolving a given hostname to its IP address. |
These options are available in Build 18980 and later.
125
123
126
-
|key|value|default|notes|
124
+
|Key|Value|Default|Notes |
127
125
|:----|:----|:----|:----|
128
126
|`default`| string | The initial username created on first run | Setting this key specifies which user to run as when first starting a WSL session. |
129
127
@@ -133,9 +131,9 @@ The Boot setting is only available on Windows 11 and Server 2022.
133
131
134
132
wsl.conf section label: `[boot]`
135
133
136
-
|key|value|default|notes|
134
+
|Key|Value|Default|Notes |
137
135
|:----|:----|:----|:----|
138
-
|`command`| string |""| A string of the command that you would like to run when the WSL instance starts. This command is run as the root user. e.g: `service docker start`.|
136
+
|`command`| string |`""`| A string of the command that you would like to run when the WSL instance starts. This command is run as the root user. e.g: `service docker start`.|
139
137
140
138
### Example wsl.conf file
141
139
@@ -203,28 +201,28 @@ This file can contain the following options that affect the VM that powers any W
203
201
204
202
.wslconfig section label: `[wsl2]`
205
203
206
-
|key|value|default|notes|
204
+
|Key|Value|Default|Notes |
207
205
|:----|:----|:----|:----|
208
206
|`kernel`| path | The Microsoft built kernel provided inbox | An absolute Windows path to a custom Linux kernel. |
209
207
|`kernelModules`| path | An absolute Windows path to a custom Linux kernel modules VHD. |
210
208
|`memory`| size | 50% of total memory on Windows | How much memory to assign to the WSL 2 VM. |
211
209
|`processors`| number | The same number of logical processors on Windows | How many logical processors to assign to the WSL 2 VM. |
212
210
|`localhostForwarding`| boolean |`true`| Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via `localhost:port`. |
213
-
|`kernelCommandLine`| string |Blank| Additional kernel command line arguments. |
214
-
|`safeMode`| boolean |`false`| Run WSL in "Safe Mode" which disables many features and is intended to be used to recover distributions that are in bad states. Only available for Windows 11 and WSL version 0.66.2+.|
215
-
|`swap`| size | 25% of memory size on Windows rounded up to the nearest GB | How much swap space to add to the WSL 2 VM, 0 for no swap file. Swap storage is disk-based RAM used when memory demand exceeds limit on hardware device. |
211
+
|`kernelCommandLine`| string |`""`| Additional kernel command line arguments. |
212
+
|`safeMode`*| boolean |`false`| Run WSL in "Safe Mode" which disables many features and is intended to be used to recover distributions that are in bad states. Only available for Windows 11 and WSL version 0.66.2+. |
213
+
|`swap`| size | 25% of memory size on Windows rounded up to the nearest GB | How much swap space to add to the WSL 2 VM, `0` for no swap file. Swap storage is disk-based RAM used when memory demand exceeds limit on hardware device. |
216
214
|`swapFile`| path |`%USERPROFILE%\AppData\Local\Temp\swap.vhdx`| An absolute Windows path to the swap virtual hard disk. |
217
215
|`pageReporting`| boolean |`true`| Default `true` setting enables Windows to reclaim unused memory allocated to WSL 2 virtual machine. |
218
-
|`guiApplications`| boolean |`true`| Boolean to turn on or off support for GUI applications ([WSLg](https://github.com/microsoft/wslg)) in WSL.|
219
-
|`debugConsole`*| boolean |`false`| Boolean to turn on an output console Window that shows the contents of `dmesg` upon start of a WSL 2 distro instance. Only available for Windows 11.|
220
-
|`nestedVirtualization`*| boolean |`true`| Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.|
221
-
|`vmIdleTimeout`*| number |`60000`| The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11.|
216
+
|`guiApplications`| boolean |`true`| Boolean to turn on or off support for GUI applications ([WSLg](https://github.com/microsoft/wslg)) in WSL.|
217
+
|`debugConsole`*| boolean |`false`| Boolean to turn on an output console Window that shows the contents of `dmesg` upon start of a WSL 2 distro instance. Only available for Windows 11.|
218
+
|`nestedVirtualization`*| boolean |`true`| Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.|
219
+
|`vmIdleTimeout`*| number |`60000`| The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11.|
222
220
|`dnsProxy`| boolean |`true`| Only applicable to networkingMode = NAT. Boolean to inform WSL to configure the DNS Server in Linux to the NAT on the host. Setting to false will mirror DNS servers from Windows to Linux. |
223
221
|`networkingMode`**| string |`NAT`| If the value is `mirrored` then this turns on mirrored networking mode. Default or unrecognized strings result in NAT networking. |
224
222
|`firewall`**| boolean |`true`| Setting this to true allows the Windows Firewall rules, as well as rules specific to Hyper-V traffic, to filter WSL network traffic. |
225
223
|`dnsTunneling`**| boolean |`true`| Changes how DNS requests are proxied from WSL to Windows |
226
224
|`autoProxy`*| boolean |`true`| Enforces WSL to use Windows’ HTTP proxy information |
227
-
|`defaultVhdSize`| size |`1099511627776` (1TB)| Set the Virtual Hard Disk (VHD) size that stores the Linux distribution (for example, Ubuntu) file system. Can be used to limit the maximum size that a distribution file system is allowed to take up. |
225
+
|`defaultVhdSize`| size |`1TB`| Set the Virtual Hard Disk (VHD) size that stores the Linux distribution (for example, Ubuntu) file system. Can be used to limit the maximum size that a distribution file system is allowed to take up. |
228
226
229
227
Entries with the `path` value must be Windows paths with escaped backslashes, e.g: `C:\\Temp\\myCustomKernel`
230
228
@@ -240,7 +238,7 @@ These settings are opt-in previews of experimental features that we aim to make
240
238
241
239
.wslconfig section label: `[experimental]`
242
240
243
-
|Setting name| Value | Default | Notes |
241
+
|Key| Value | Default | Notes |
244
242
|:----|:----|:----|:----|
245
243
|`autoMemoryReclaim`| string |`dropCache`| Automatically releases cached memory after detecting idle CPU usage. Set to `gradual` for slow release, and `dropCache` for instant release of cached memory. |
246
244
|`sparseVhd`| bool |`false`| When set to true, any newly created VHD will be set to sparse automatically. |
0 commit comments