Open14

WSL2 の distro がエラー 0xffffffff で死ぬ

wintwint

モチベ

問題とトラブルシュートしたい

参考資料

https://learn.microsoft.com/ja-jp/windows/wsl/troubleshooting

issues

https://github.com/microsoft/WSL/issues/4929#issuecomment-734713437

https://github.com/microsoft/WSL/issues/4432#issuecomment-528185325

https://github.com/microsoft/WSL/issues/4364#issuecomment-520533800

others

https://wand-ta.hatenablog.com/entry/2020/03/25/233618

https://stackoverflow.com/a/64217462/3576692

https://stackoverflow.com/a/68319801/3576692

WSL2 needs ports 53 in order to function. So now I have a port conflict. Is there any way to change the port WSL uses?
It turns out it was a Windows Service which used the port 53 called SharedAccess.
You can stop it by doing this command net stop sharedaccess And permanently disabling it by going into services.msc (The Internet Connection Sharing (ICS))

https://www.hanselman.com/blog/your-computer-is-not-a-black-box-understanding-processes-and-ports-on-windows-by-exploring

自分の環境

  • Windows 10
  • sinkhole DNS Server として Technitium DNS Server を使ってる

https://technitium.com/dns/

wintwint

再現

nslookup www.google.co.jp 172.31.240.1
DNS request timed out.
    timeout was 2 seconds.
サーバー:  UnKnown
Address:  172.31.240.1

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** UnKnown への要求がタイムアウトしました
Resolve-DnsName -Name google.com -Server 172.31.240.1
Resolve-DnsName -Name google.com -TcpOnly
wintwint

解決案

netsh interface portproxy add v4tov4 listenaddress=172.31.240.1 listenport=53 connectaddress=10.0.0.1
netsh interface portproxy show all
wintwint

ダメだった

D:\backups\WSL
❯ wsl -l
Linux 用 Windows サブシステム ディストリビューション:
Ubuntu (既定)
WLinux
Ubuntu-20.04

D:\backups\WSL
❯ wsl --export Ubuntu Ubuntu-20220810.tar
エラー: 0xffffffff

D:\backups\WSL took 3s
❯ wsl --export Ubuntu-20.04 Ubuntu-20.04--20220810.tar
エラー: 0xffffffff

D:\backups\WSL
❯ wsl --export WLinux WLinux-20220810.tar
エラー: 0xffffffff
wintwint

しょうがないので、 distro アプリを全部アンインストールするところから始める。

logs:

wsl --unregister WLinux

Ubuntu 2つは GUI から(詳細オプション内の)リセットを試す。その後、削除。

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0xffffffff
Error: 0xffffffff (null)

最後に WSL 自体を一旦 無効化

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
wintwint

記録

disk clone 後からは、起動するタイミングがあった。

詳細な条件は不明。

wintwint

今日も今日とて相変わらずエラー。ここ数週間おなじ。

Error: 0xffffffff
Error code: Wsl/Service/CreateInstance/CreateVm/ConfigureNetworking/0xffffffff

[プロセスはコード 4294967295 (0xffffffff) で終了しました]

Windows Terminal でも Ubuntu on Windows アプリでも同様。

関連

https://github.com/microsoft/WSL/issues/4929

https://github.com/microsoft/WSL/issues/4939#issuecomment-593152539

https://www.surfacetablethelp.com/2018/10/fix-hyper-v-not-working-after-windows-10-v1809-upgraded.html

https://github.com/microsoft/WSL/issues/5092

https://github.com/microsoft/WSL/issues/5110#issuecomment-630690859
https://github.com/microsoft/WSL/issues/5110#issuecomment-1084374969

https://github.com/microsoft/WSL/issues/8455