Hyper-VのWindows10仮想マシンでWSL2を動作させる

スポンサーリンク
スポンサーリンク

Hyper-Vの仮想マシンで、Windows10を動かしていて、そのWindows上でWSL2を使う場合の設定です。

WSL2を使おうとして、wsl –set-default-version 2 や wsl –set-version “仮想マシン名” 2 を実行したら、次のいずれかの表示が出た場合に本記事の設定を行って下さい。

Windows の仮想マシン プラットフォーム機能を有効にして、BIOS で仮想化が有効になっていることを確認してください。
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.

ホストマシンでの設定

仮想マシンがシャットダウンしている状態で、PowerShell で次を実行します。

Set-VMProcessor -VMName "Hyper-Vの仮想マシン名" -ExposeVirtualizationExtensions $true

なお、チェックポイントの適用で上記コマンド実行前に戻した際は、改めてコマンドを実行してください。

ゲストの仮想マシンでの設定

ゲストのWindows10仮想マシン上で、次のサイトの「手順 4 – Linux カーネル更新プログラム パッケージをダウンロードする」を実行します。

Install WSL
Install Windows Subsystem for Linux with the command, wsl --install. Use a Bash terminal on your Windows machine run by ...

続けて、 PowerShell で次を実行します。

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

以上で、 Hyper-VのWindows10仮想マシン上で、WSL2が使用できるようになります。

参考

WSL2 on Hyper-V│チラシの裏

コメント

タイトルとURLをコピーしました