启动

常见问题

  • Windows文件管理器直接访问wsl2内容器系统文件夹
    • 访问\\wsl$
  • wsl2内访问Windows文件
    • 访问/mnt/
  • 使用主机代理
    • http proxy设置为主机ip+端口
  • 无法升级到2或者systemd无法使用
    • 需要用管理员权限打开cmd运行wsl --update
  • 让同网络其他设备访问指定wsl2暴露的端口
    • 首先设置服务listen 0.0.0.0:port
    • wsl2中ip addr | grep eth0找到wsl2的虚拟ip(这个ip每次重启wsl2都会再分配)
    • CMD中设置netsh interface portproxy add v4tov4 listenport=port connectaddress=ip_address connectport=port来进行一次端口转发(netsh interface portproxy delete v4tov4 listenport=port取消转发)
  • SSH访问时报错Wsl/Service/CreateInstance/CreateVm/HCS/HCS_E_SERVICE_NOT_AVAILABLE ^9ce3c4
    • 启动的前提是VMP和WSL在Windows中已经启动(但好像远程的这俩状态和物理机上操作时并不一样?)
    • 切换成Power Shellpowershell.exe(需要管理员权限)
    • 检查VMP状态:dism /online /get-featureinfo /featurename:VirtualMachinePlatform
    • 启用WSL和VMP:
      • dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
      • dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    • 重启
    • 启动WSL