doc/docs/technical-documentation/init.md
Init is top level process of a WSL distribution. For WSL1 distributions, it is launched by wslservice (see src/windows/service/LxssInstance.cpp) and for WSL2 distributions, it is launched by mini_init.
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:
LxMiniInitMessageLaunchInit message).While each distribution runs in its own mount namespace, the /mnt/wsl mountpoint is shared between all distributions.
Once started, the init process performs various initialization tasks such as:
/proc, /sys and /devdrvfs drives (See drvfs)wslg (see wslg)Once ready, init establishes either an lxbus (WSL1) or an hvsocket (WSL2) connection to wslservice. This channel is used to transmit various commands to init (see src/shared/inc/lxinitshared.h), such as:
LxInitMessageInitialize: Configure the distributionLxInitMessageCreateSession: Create a new session leader. See session leaderLxInitMessageTerminateInstance: Terminate the distribution