mirror of
https://github.com/microsoft/WSL.git
synced 2025-07-04 07:43:21 +00:00

Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016. The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021: Number of commits on the main branch: 2930 Number of contributors: 31 Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
36 lines
1.8 KiB
Markdown
36 lines
1.8 KiB
Markdown
# mini_init
|
|
|
|
mini_init is the first executable that's launched when the WSL2 virtual machine starts. See [WSL2 boot process](boot-process.md) for more details.
|
|
|
|
## Virtual machine setup
|
|
|
|
mini_init is started when the kernel is done booting, and calls `/init`, which is `mini_init`. Like other standard linux `init` executables, `mini_init` starts by mounting `/proc`, `/sys`, `/dev` and other standard mountpoints.
|
|
|
|
`mini_init` then performs various configuration such as enabling crash dump collection, configuring logging via `/dev/console` and tty configuration.
|
|
|
|
Once everything is ready, `mini_init` connects two hvsockets to [wslservice](wslservice.exe.md).
|
|
|
|
One of them, called the "mini_init" channel is used for messages sent by `wslservice.exe`. See `src/shared/inc/lxinitshared.h` for a list of messages and responses. Common messages are:
|
|
|
|
- `LxMiniInitMessageLaunchInit`: Mount a virtual disk and start a new distribution. See [`init`](init.md) for more details
|
|
- `LxMiniInitMessageMount`: Mount a disk in `/mnt/wsl` (used for wsl --mount)
|
|
- `EJECT_VHD_MESSAGE`: Eject a disk
|
|
- `LxMiniInitMessageImport`: Import a distribution
|
|
- `LxMiniInitMessageExport`: Export a distribution
|
|
|
|
The other hvsocket channel is used to send notifications to [wslservice.exe](wslservice.exe.md). This is used mainly to report when linux processes exit (which wslservice uses to know when distributions are terminated).
|
|
|
|
## Networking configuration
|
|
|
|
As part of the boot process, `mini_init` also launches the [gns binary](gns.md) which managed networking configuration
|
|
|
|
## Other tasks
|
|
|
|
`mini_init` performs various other maintenance tasks such as:
|
|
|
|
- Reclaiming unused memory
|
|
- Launching the debug shell tty
|
|
- Synchronizing IO when the virtual machine terminates
|
|
- Resizing filesystem (for wsl --manage <distro> --resize)
|
|
- Formatting disks (used when installing new distributions)
|
|
|