Skip to content

wsl

查看基本信息

wsl -l -v

关闭系统

wsl --shutdown

导出虚拟系统

wsl --export {wslName} {location/name.tar}

注销虚拟系统

此会删除虚拟系统,释放磁盘空间

wslconfig /u {wslName}

导入虚拟系统

wsl --import {wslName} {系统的存放位置} {系统tar路径}

其他,查看安装位置

(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '{wslName}' }).GetValue("BasePath") + "\ext4.vhdx"

配置

.wslconfig

在 %UserProfile% 目录下创建 .wslconfig 文件,配置如下:

  • 配置指定内存
[wsl2]
memory=14GB
  • 配置wsl走网络代理
[experimental]
autoMemoryReclaim=gradual  
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

Comments