wsl2-expert

Reference WSL2 configuration, CLI commands, distro packaging, and diagnostics for Windows Subsystem for Linux.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/psmfd/pi-config --skill wsl2-expert-psmfd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: wsl2-expert
Source: https://github.com/psmfd/pi-config/tree/main/agent/skills/wsl2-expert
Command: npx skills add https://github.com/psmfd/pi-config --skill wsl2-expert-psmfd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? WSL2 configuration is error-prone because settings are split between the in-guest /etc/wsl.conf and the host-side .wslconfig, defaults shift across Windows builds, and systemd, networking, and interop behaviors are version-gated. This Skill provides a curated, cross-linked reference so answers about wsl.exe, distro lifecycle, and diagnostics stay accurate and safe. ## Core Features & Use Cases - Configuration guidance: Distinguishes /etc/wsl.conf (per-distro, in-guest) from .wslconfig (global, host-side) with annotated key references for automount, network, interop, boot, and wsl2 sections. - Distro packaging via wsl --import: Documents the rootfs tarball production path (docker export), import semantics, /etc/wsl-distribution.conf OOBE contract, and the supply-chain trust boundary of importing tarballs. - Diagnostics and networking: Provides copy-paste diagnostic recipes (wsl --version, /dev/kvm checks, wslinfo) and explains NAT vs mirrored networking modes, systemd enablement, and CI runner constraints. - Use Case: When asked why systemd is not starting in a WSL2 distro, the Skill directs checking wsl --version for the 0.67.6 runtime gate, confirming [boot] systemd=true in /etc/wsl.conf, and applying it with wsl --shutdown. ## Quick Start Ask the wsl2-expert subagent how to package a Linux rootfs tarball and import it as a WSL2 distro with wsl --import.

Frequently Asked Questions about wsl2-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable systemd in WSL2?▼

Enable systemd in WSL2 by adding [boot] systemd=true to /etc/wsl.conf inside the distro, then running wsl --shutdown from PowerShell to apply it. The WSL runtime must be version 0.67.6 or newer; older runtimes silently ignore the key, so check wsl --version first.

What is the difference between /etc/wsl.conf and .wslconfig?▼

/etc/wsl.conf lives inside each Linux distro and is consumed per-distro at distro start, while .wslconfig lives at %UserProfile%\.wslconfig on the Windows host and applies globally to all WSL2 distros at utility-VM start. Misplacing a key fails silently because the wrong consumer ignores it.

How do I import a custom Linux rootfs as a WSL2 distro?▼

Import a custom rootfs with wsl --import <Name> <InstallLocation> <rootfs.tar> --version 2, where the tarball is a flat root filesystem such as one produced by docker export. Verify tarball provenance and audit [boot] command= entries and shipped systemd units first, since the tarball author gains code execution on first launch.

Does WSL2 support nested virtualization and /dev/kvm?▼

WSL2 exposes /dev/kvm when the host CPU supports VT-x+EPT or AMD-V+RVI, the VirtualMachinePlatform feature is enabled, and nestedVirtualization=true is set in .wslconfig. It is not available on GitHub Actions Microsoft-hosted Windows runners, so KVM-dependent CI steps need self-hosted runners or Linux runners.

Why is localhost networking different between WSL2 NAT and mirrored mode?▼

NAT mode gives the WSL utility VM a private subnet with localhostForwarding proxying traffic, while mirrored mode lets the guest share the Windows host's interfaces and localhost directly. Mirrored mode changes firewall and DNS behavior and can break Docker-in-WSL2 setups, so test before switching.

Should I use \\wsl$ or \\wsl.localhost to access WSL files from Windows?▼

Use \\wsl.localhost\<Distro>\ for new tooling, as it is the modern UNC root documented on current MS Learn pages. The legacy \\wsl$\<Distro>\ form still works as a backward-compatible alias but should only be mentioned for compatibility with older scripts.