1 *.bat文件安装hyper-v
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
2 Windows powerShell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --install 安装wsl
wsl --update 更新wsl
wsl --set-default-version 2 # 将WSL版本设置为2(可选,但不是必须的)
wsl --install Ubuntu-20.04microsoft store 安装ubuntu
wsl --export Ubuntu-20.04 D:\ubuntu.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 D:\ubuntu D:\ubuntu.tar
lsb_release -a 查看ubuntu 版本
wsl --list --verbose
wsl -l -v 查看ubuntu
wsl -d ubuntu-20.04