2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows update 後の WSL2 起動不良への対処法

Posted at

Windows update 後の WSL2 起動不良への対処法

背景

Windows Update 実行後、WSL2 が起動しなくなり、原因特定に時間がかかったため備忘として残します。

環境

  • Windows 11
  • WSL2 Ubuntu20.04

症状

  • ターミナルからWSL2 を起動すると、文字化けし起動できなくなる。
  • エクスプローラーから、WSL 関連のフォルダが消失する。(Windows 側がWSL を認識できなくなる。)
  • /etc/resolv.conf 内の nameserver 設定が異常になり IP 割り当てに不具合が発生。
    起動時出力
    Installing, this may take a few minutes...
    WslRegisterDistribution failed with error: 0x8007019e
    Error: 0x8007019e Linux ? Windows ?????????????????????'wsl.exe --install' ????????????????
    ????????https://aka.ms/wslinstall ???????????
    
    Press any key to continue...
    

原因 (推測)

  1. WSL2 が起動しない
    これは、Windows 11 バージョン 24H2 へのアップデート後に、WSL2 のカーネルバージョンとの互換性に問題が生じ、起動時にクラッシュする可能性がある。
    このため、以下のコマンドで WSL の各コンポーネントを最新版に更新する必要があります。

    wsl.exe --update
    
  2. Windows から WSL が認識されなくなる
    WSL が旧バージョンのままだと、Windows 側から認識されなくなるケースがあります。
    エクスプローラーからのフォルダアクセスも不能になります。

  3. 名前解決ができない
    .wslconfigdnsTunneling が、24H2 アップデート後にデフォルトで有効(true)になることで、DNS 解決に失敗するケースがあります。

    ドキュメント上は 22H2 から利用可能とされていますが、24H2 + wsl.exe --update のタイミングで強制的に適用される可能性があります。

dnsTunneling 有効時の /etc/resolv.conf
WSL が起動時に Windows 側の DNS を使用するようになり、以下のような内容が自動生成されます。

/etc/resolv.conf
nameserver 10.255.255.254 # 仮想 IP アドレス (WSL 用内部 DNS)
search yourdomain.local # Windows 側が提供するプライベートドメイン

dnsTunneling 無効時の /etc/resolv.conf
WSL2 のグローバル IP が振られるようになる。

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.xx.xx.xx

対応手順

  1. cmd にて、WSL をアップデート
    wsl.exe --update
    
  2. OS 再起動
  3. .wslconfig の設定変更
    C:\Users\(ユーザー名)\.wslconfig に以下を追記
    .wslconfig
    [WSL2]
    + dnsTunneling=false
    

    dnsTunneling は [WSL2] セクションに記載する必要があります。
    Windows バージョン 22H2 以降で正式に [WSL2] セクションの設定項目に昇格しています。

  4. wsl 再起動
    wsl --shutdown
    

参考

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?