docs.microsoft.com: wslapi.h header
docs.microsoft.com: Manually download Windows Subsystem for Linux distro packages
docs.microsoft.com: Enable or Disable Windows Features Using DISM
docs.microsoft.com: Example: Getting WMI Data from the Local Computer
docs.microsoft.com: Querying the Status of Optional Features
docs.microsoft.com: Win32_OptionalFeature (Windows Management Instrumentation)
github.com/microsoft/WSL#2635: No ... way to create an AppX bundle for a Linux distribution from scratch (custom distributions)
github.com/microsoft/WSL-DistroLauncher: "Installing, this may take a few minutes..." as seen on first launch of appx
Stack Overflow: What's “EXISTS WIN://SYSAPPID” condition in “C:\Program Files\WindowsApps” ACL?
/r/bashonubuntuonwindows/: Using WSL-DistroLauncher - example distro .tar.gz files?
salsa.debian.org/rhaist-guest/WSL: WSL Distro Launcher Reference Implementation
salsa.debian.org/rhaist-guest/WSL/create-targz.sh
renenyffenegger.ch: Windows Subsystem for Linux (WSL)
C:\local>wsl -d Ubuntu-16.04 cat /proc/version
Linux version 4.4.0-19041-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #488-Microsoft Mon Sep 01 13:43:00 PST 2020
C:\local>wsl -d Ubuntu-18.04 cat /proc/version
Linux version 4.4.0-19041-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #488-Microsoft Mon Sep 01 13:43:00 PST 2020
C:\local>wsl -d Ubuntu-20.04 cat /proc/version
Linux version 4.4.0-19041-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #488-Microsoft Mon Sep 01 13:43:00 PST 2020
C:\local>wsl -d Ubuntu cat /proc/version
Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020
WSL2 has X11(?) support for easy GUI shit:
C:\> wsl --install Ubuntu-22.04
...setup username/password...
monkey@necromancy:~$ sudo apt-get update
...
monkey@necromancy:~$ sudo apt-get install mesa-utils
...
monkey@necromancy:~$ glxgears
...see cool window...
C:\> wsl --unregister Ubuntu-22.04
...cleaned up...
docs say api-ms-win-wsl-api-l1-1-0.dll
wslapi.dll
is a thing too: dumpbin /exports "%SystemRoot%\System32\wslapi.dll"
:
...
1 0 00001110 WslConfigureDistribution
2 1 00001200 WslGetDistributionConfiguration
3 2 000023A0 WslIsDistributionRegistered
4 3 00002CA0 WslLaunch
5 4 00002DB0 WslLaunchInteractive
6 5 00002480 WslRegisterDistribution
7 6 00002570 WslUnregisterDistribution
...
Nice clean C
ish API. (Un)register tarballs.
:: get your own SID
wmic useraccount where name='%USERNAME%' get sid
:: Check/install WSL 1 (note: dism requires elevation, wmic doesn't)
wmic path Win32_OptionalFeature where name="Microsoft-Windows-Subsystem-Linux" get InstallState
dism /online /enable-feature /featureName:Microsoft-Windows-Subsystem-Linux
:: Upgrade to WSL 2?
dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
:: Install Ubuntu
curl -L -o ubuntu-1604.appx https://aka.ms/wsl-ubuntu-1604
Add-AppxPackage ubuntu-1604.appx
:: ...launch appx?...
:: Run stuff
bash --login -c "echo \"why hello there\""
wsl --distribution Ubuntu -- /usr/bin/env bash --login -c "echo \"why hello there\""
NOTE: wsl
might bypass a lot of shell/env setup by default? I swear I needed all that --login
magic and nonsense at one point for basic ${PATH}
setup to work right... or maybe that was necessary to avoid having WSL change my CWD? I can no longer get it to mistreat me as I remember it historically doing...
ubuntu-1604.appx
can be unzipped via 7-zip, and contains ubuntu1604.exe
(launcher/installer?) and install.tar.gz
(can probably be fed straight to WslRegisterDistribution
?)
- Where all the appx files get unpackaged to?
- Magic account has Read & Execute permissions:
S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204
- Is this the old user you have to grant permissions to for appx packages to access the regular filesystem?
- Also has magic
Exists WIN://SYSAPPID
condition on Users ACL
C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1604.2017.922.0_x64__79rhkp1fndgsc\
- Where the ubuntu appx supposedly is... might contain the .tar.gz
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{lower-case-guid}\...
HKEY_USERS\...\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{lower-case-guid}\...
DefaultUid == 0
means root
Version
refers to the original version? wsl --list -v
returns 2 for all versions
State
is unrelated to running/stopped state?
DefaultEnvironment
, KernelCommandLine
, and PackageFamilyName
are all optional
Name | Type | Value |
---|---|---|
(Default) | REG_SZ | (value not set) |
BasePath | REG_SZ | \\?\%USERPROFILE%\AppData\Local\Docker\wsl\data |
DefaultUid | REG_DWORD | 0 |
DistributionName | REG_SZ | docker-desktop-data |
Flags | REG_DWORD | 0xF |
State | REG_DWORD | 0x1 |
Version | REG_DWORD | 2 |
Name | Type | Value |
---|---|---|
(Default) | REG_SZ | (value not set) |
BasePath | REG_SZ | \\?\%USERPROFILE%\AppData\Local\Docker\wsl\distro |
DefaultUid | REG_DWORD | 0 |
DistributionName | REG_SZ | docker-desktop |
Flags | REG_DWORD | 0xF |
State | REG_DWORD | 0x1 |
Version | REG_DWORD | 2 |
Name | Type | Value |
---|---|---|
(Default) | REG_SZ | (value not set) |
BasePath | REG_SZ | %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState |
DefaultEnvironment | REG_MULTI_SZ | HOSTTYPE=x86_64 |
LANG=en_US.UTF-8 |
||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games |
||
TERM=xterm-256color |
||
DefaultUid | REG_DWORD | 1000 |
DistributionName | REG_SZ | Ubuntu |
Flags | REG_DWORD | 0xF |
KernelCommandLine | REG_SZ | BOOT_IMAGE=/kernel init=/init |
PackageFamilyName | REG_SZ | CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc |
State | REG_DWORD | 1 |
Version | REG_DWORD | 1 |