microsoft / microsoft/WSL

WSL Containers: support persistent sysctl configuration (e.g. vm.max_map_count)

Open
#41,029 2 comments 2 reactions 0 assignees View on GitHub
feature wslc
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

I am using the latest WSL preview version:
```
WSL version: 2.9.3.0
Kernel version: 6.18.35.2-1
```
WSL Containers runs in a dedicated session VM where kernel parameters can be modified interactively:
```console
wslc system session shell
/usr/sbin/sysctl -w vm.max_map_count=262144
```
or like this
```console
wslc system session run /usr/sbin/sysctl -w vm.max_map_count=262144
```
However, the session is ephemeral. After the session is terminated and restarted, the value is reset to the default (65530).
This prevents running workloads such as Elasticsearch or OpenSearch without executing an initialization command after every new session.
It would be useful to support persistent kernel parameters, for example in `settings.yaml`:
```yaml
session:
sysctl:
vm.max_map_count: 262144
```
or any equivalent mechanism executed when a new session is created.
I tried using the `.wslconfig` file with:
```ini
[wsl2]
kernelCommandLine="sysctl.vm.max_map_count=262144"
```
but it doesn't affect the wslc session configuration (only the WSL distributions)

Contributor guide

Open the contributing guide

Research direction

Reproduce the reset with `wslc system session run /usr/sbin/sysctl -w vm.max_map_count=262144`, then restart the session and compare the value. Start by tracing how session creation reads `settings.yaml` and why `.wslconfig` does not affect WSL Containers; done means a configured value such as `vm.max_map_count: 262144` is applied whenever a new session starts.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.