Skip to content

WSL rootfs on newer OS builds is no longer "%LOCALAPPDATA%\lxss" #9298

@BR0kEN-

Description

@BR0kEN-

Vagrant version

Vagrant 2.0.2

Host operating system

Windows 10 (version 1709, build 16299.125).

Expected behavior

Vagrant is to detect current WSL container and compute a proper path to it.

Actual behavior

Vagrant handles only the WSL that is installed via lxrun.

References

Additional information

Before the 16215 build of Windows, there was a way to install a WSL using lxrun. After mentioned build this way has been deprecated and, since then, it's recommended to use Microsoft Store for installing a WSL. Moreover, since that version, you can have multiple instances of Linux subsystem.

When the installation is done by lxrun /install then rootfs of a WSL will be in %LOCALAPPDATA%\lxss and Vagrant will operate correctly since its codebase relies on this location (https://github.com/hashicorp/vagrant/blob/v2.0.1/lib/vagrant/util/platform.rb#L286-L289).

lxrun installation

When the installation is done from the Microsoft Store, then rootfs of a WSL will be in %LOCALAPPDATA%\Packages\<WSL_ID>\LocalState. Pay your attention at the <WSL_ID> token in the path which is completely dynamic.

installation from store

The path of the particular container can be obtained from the registry at HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss - a listing of installed subsystems.

For instance, using the following PowerShell script, the path of default subsystem can be gained.

$WSLREGKEY="HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss"
$WSLDEFID=(Get-ItemProperty "$WSLREGKEY").DefaultDistribution
$WSLFSPATH=(Get-ItemProperty "$WSLREGKEY\$WSLDEFID").BasePath
New-Item -ItemType Junction -Path "$env:LOCALAPPDATA\lxss" -Value "$WSLFSPATH\rootfs"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions