initrd binary to experiment with WSLg in Windows 10
Table of contents
This program assumes some certain aspects by default which are as following:
This project has been tested in Windows 10 21H1 Version 10.0.19043.928. The messages between initrd and Lxss service are varied with Windows versions. Feel free to modify this project for your own Windows version.
Every binaries are compiled in Alpine Linux and with musl libc & gcc. Feel free to use any compiler toolchain and libc.
- Download WSL msixbundle package from WSL Release page. In that msixbundle, extract the ARM64 or X64 msix according to your CPU architecture. Extract the msix in
C:\WSLpath (default) or at your choice (need modification). Use any program that can extract from ZIP format e.g. unzip, 7zip etc.
C:\WSLdirectory, convert the system.vhd to ext4.vhdx file. Because Lxss service expects the WSL distribution in exactly ext4.vhdx named file. Use this command in Powershell.
Convert-VHD -Path "system.vhd" -DestinationPath "ext4.vhdx"
Double click on the SystemDistro.reg file to register the ext4.vhdx file with "system" named distribution in WSL2 environment. Make sure there is no distribution with "system" name before that.
Backup and Rename the initrd.img file in
C:\Windows\System32\lxss\toolsdirectory to something else. Clone this repository. Run
makecommand in any GNU/Linux distribution to compile the initrd.img file. Copy the newly compiled initrd.img file to that
Check out Win10 branch in my fork of wslg. Run
makecommand in WSLGd directory to compile WSLGd static executable. Remember the full path of that for later use.
How to use
Run your preferred GNU/Linux distribution in WSL2.
wsl.exe -d systemto run the newly registered "system" distribution.
Run the following commands in both your running distribution and "system" distribution as well. This step may not required in future, just thoughts. The
<guid>is retrieved from
hcsdiag.exe listcommand output.
export WAYLAND_DISPLAY=wayland-0 export DISPLAY=:0 export XDG_RUNTIME_DIR=/mnt/wsl/runtime-dir export PULSE_SERVER=/mnt/wsl/PulseServer export WSL2_INSTALL_PATH="C:\\WSL" export WSL2_VM_ID=<guid>
Run previously compiled WSLGd binary in "system" distribution. The WSLGd will invoke
C:\WSL\msrdc.exeexecutable and show a warning window to accept network connections. Click on "Connect" button to allow it.
Now run any GUI program in your distribution
Differences with initrd
This project is not an replacement of initrd binary which already exists in Windows 10 and 11 systems. This does NOT do:
- Import or export distributions in WSL2.
- Convert distributions from WSL1 to WSL2 or vice-versa.
- Create or attach swap file.
- Execute localhost or telemetry processes.
- Compact memory.
Everyone in the discussions:
Free and Open source projects:
This project is licensed under GNU General Public License version 3 or any later version at your option. See LICENSE file for further details.