Files
WSL/doc/docs/technical-documentation/init.md
Ben Hillis 8c220dc083 Fix grammar, typos, and formatting in docs and source (#14286)
* Fix localization text, Intune capitalization, ADMX indentation, unused import

- distributions/validate.py: Remove unused 'import base64'
- en-US/en-GB Resources.resw: Fix word order 'the list distribution' -> 'the distribution list' in MessageCouldFetchDistributionList
- en-US/en-GB Resources.resw: Remove trailing space from MessageCorruptedDistroRegistration value
- intune/en-US/WSL.adml: Fix 'For Linux' -> 'for Linux' capitalization (5 occurrences) to match official product name
- intune/WSL.admx: Fix inconsistent 3-space indent to 4-space on AllowWSL1 and CustomKernelUserSettingConfigurable policies

* Fix grammar, typos, and formatting in docs and source code

- WmiService.h: Fix duplicated word 'of of' -> 'is of' in WQL comment
- drvfs.md: Fix 'which tell' -> 'which tells' (subject-verb agreement), double space, second 'tell' -> 'tells'
- systemd.md: Fix 'tries synchronizes' -> 'tries to synchronize'
- wslhost.exe.md: Fix 'processes terminates' -> 'process terminates'
- boot-process.md: Add missing 'in' preposition, fix C:/ -> C:\, fix lowercase 'linux' to 'Linux' (4 occurrences), fix misplaced parenthesis
- init.md: Fix double space before hvsocket backtick
- session-leader.md: Fix heading level ## -> ### to match sibling section
- CONTRIBUTING.md: Fix double period after bold security notice
- debugging.md: Fix missing word 'be' in 'can enabled', fix 'process' -> 'processes'
- index.md: Add missing period at end of sentence
- technical-documentation/index.md: Fix 'API's' -> 'APIs' (remove incorrect apostrophe)
- relay.md: Fix lowercase 'linux' to 'Linux' (3 occurrences)
- localhost.md: Fix lowercase 'linux' to 'Linux'
- plan9.md: Fix lowercase 'linux' to 'Linux'

* update errormessages testcase

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
2026-03-03 18:13:59 -08:00

36 lines
1.7 KiB
Markdown

# Init
Init is top level process of a WSL distribution. For WSL1 distributions, it is launched by [wslservice](wslservice.exe.md) (see `src/windows/service/LxssInstance.cpp`) and for WSL2 distributions, it is launched by [mini_init](mini_init.md).
## WSL2 specific distributions startup
Each WSL2 distributions runs in a separate mount, pid and UTS namespace. This allows distributions to run in parallel, without "seeing" each other.
When a WSL2 distribution starts, [mini_init](mini_init.md):
- Mounts the distribution VHD
- Clones into a child namespace
- Chroots in the VHD mountpoint
- Executes init (see the `LxMiniInitMessageLaunchInit` message).
While each distribution runs in its own mount namespace, the `/mnt/wsl` mountpoint is shared between all distributions.
## Distribution initialization
Once started, the `init` process performs various initialization tasks such as:
- Mounting `/proc`, `/sys` and `/dev`
- Configuring cgroups
- Registering the binfmt interpreter (see [interop](interop.md))
- Parsing [/etc/wsl.conf](https://learn.microsoft.com/windows/wsl/wsl-config)
- Starting systemd (see [systemd](systemd.md))
- Mounting `drvfs` drives (See [drvfs](drvfs.md))
- Configuring `wslg` (see [wslg](https://github.com/microsoft/wslg))
## Running the distribution
Once ready, `init` establishes either an `lxbus` (WSL1) or an `hvsocket` (WSL2) connection to [wslservice](wslservice.exe.md). This channel is used to transmit various commands to `init` (see `src/shared/inc/lxinitshared.h`), such as:
- `LxInitMessageInitialize`: Configure the distribution
- `LxInitMessageCreateSession`: Create a new session leader. See [session leader](session-leader.md)
- `LxInitMessageTerminateInstance`: Terminate the distribution