WSL/doc/docs/technical-documentation/mini_init.md
WSL Team 697572d664 Initial open source commit for WSL.
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.
2025-05-15 12:09:45 -07:00

1.8 KiB

mini_init

mini_init is the first executable that's launched when the WSL2 virtual machine starts. See WSL2 boot process 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.

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 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. 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 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 --resize)
  • Formatting disks (used when installing new distributions)