本來電腦上已經(jīng)配好了一個(gè)相當(dāng)好用的WSL2,卻因?yàn)槲蚁朐倥渲靡粋€(gè)安卓虛擬機(jī)導(dǎo)致二者不兼容员串,“自動修復(fù)”過程中直接搞死了WSL,因此不得不重新配置一遍欲诺,還遇到了一個(gè)經(jīng)典報(bào)錯(cuò)扰法,可供大家借鑒。
微軟的官方文檔https://docs.microsoft.com/zh-cn/windows/wsl/install-win10提供了相當(dāng)全面的流程塞颁,但實(shí)際操作中似乎仍可能遇到各種各樣的問題殴边,故在此做一定補(bǔ)充珍语。
啟用各種設(shè)置
- 在“控制面板”-“啟用或關(guān)閉Windows功能”中板乙,需要開啟Hyper-V募逞、適用于Linux的Windows子系統(tǒng)馋评、虛擬機(jī)平臺三個(gè)選項(xiàng),勾選后需要重啟纠脾。
- 在命令行也可以完成以上操作
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- 開啟Hyper-V需要將如下腳本寫為.cmd腳本后運(yùn)行
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
-
若為amd處理器則為Amd虛擬技術(shù)
設(shè)置與安裝
- 將WSL2設(shè)置為默認(rèn)版本
wsl --set-default-version 2
- 從Microsoft Store安裝想要的Linux版本
問題與解決措施
按照上面的操作一套下來糊渊,我仍然在啟動Ubuntu20.04時(shí)報(bào)錯(cuò)渺绒,錯(cuò)誤如下:
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Error: 0x80370102 ????????????????
或者有的遇到錯(cuò)誤為:
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Error: 0x80370102 The virtual machine could not be started because a required feature is not installed.
錯(cuò)誤編號一樣宗兼,應(yīng)該也是同一個(gè)問題
解決方法:命令行啟動Hyper-V(注意以管理員運(yùn)行powershell或cmd)
bcdedit /set hypervisorlaunchtype auto