下载 Ubuntu
Ubuntu_2004.2020.424.0_x64.appx
安装
Add-AppxPackage .\Ubuntu_2004.2020.424.0_x64.appx
需管理员权限运行 PowerShell
错误
- WslRegisterDistribution failed with error:
0x8007019e
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
运行命令后重启
- WslRegisterDistribution failed with error:
0x800701bc
内核没有升级:下载 Linux 内核更新包
wsl 命令
wsl -h # 查看帮助
wsl -l -v # 列出子系统的详细信息
wsl --set-version Ubuntu-20.04 2 # 切换至 wsl 2
wsl --set-default-version 2 # 默认 wsl 2
wsl -t Ubuntu-20.04 # 关闭子系统
wsl -d Ubuntu-20.04 # 运行子系统
# 迁移
wsl --export Ubuntu-20.04 .\Ubuntu-20.04.tar
wsl --unregister Ubuntu-20.04
wsl --import <IMPORT_DISTRIBUTION_NAME> <IMPORT_PATH> <EXPORT_PATH>
# 迁移后默认是 wsl 1
wsl -- hostname -I # 获取IP
固定 WSL2 IP
@echo off
setlocal enabledelayedexpansion
wsl -t Ubuntu-20.04
wsl -u root ip addr | findstr "172.29.221.1" > nul
if !errorlevel! equ 0 (
echo wsl ip has set
) else (
wsl -u root ip addr add 172.29.221.1/20 broadcast 172.29.223.255 dev eth0 label eth0:1
echo set wsl ip success: 172.29.221.1
)
ipconfig | findstr "172.29.220.1" > null
if !errorlevel! equ 0 (
echo windows ip has set
) else (
netsh interface ip set address "vEthernet (WSL)" static 172.29.220.1 255.255.240.0
echo set windows ip success: 172.29.220.1
)
需管理员权限运行
网友评论