1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

UBuntu 22.04 をWSL2 環境で動かすメモ

Last updated at Posted at 2023-09-30

下記手順で実行する。

WSL2の有効化

・Win+R → control でコントロールパネルを開く
・プログラム → Windowsの機能の有効化または無効化から、下記3つを有効化。OKボタン押下後、再起動。
 1,Linux用Windowsサブシステム
 2,Windowsハイパーバイザープラットフォーム
 3,仮想マシン プラットフォーム
・Windows Terminal をMicrosoft Store から入手し、Windows terminal上で wsl --set-default-version 2 を実行
・コマンド実行結果にある https://aka.ms/wsl2kernel を任意のブラウザで開く
最新のWSL 2 Linuxカーネル更新プログラムパッケージ リンクをクリックしてダウンロードし、インストールを実行
・Windows terminal上で wsl --set-default-version 2 を実行し、先ほどと表示されるメッセージが変わっていることを確認

Ubuntuインストール

・Microsoft Store にて"Ubuntu"で検索し、任意のディストリビューションを選択して「入手」を実行
※ここで"Ubuntu" を選択して入手したところ、後々エラーが発生したので Ubuntu 22.04 を推奨(2023/09/29時点)
以降はWindows Terminal より操作すればよい。

トラブル発生時:Ubuntuアンインストール方法

・Microsoft Store にて、Ubuntu 22.04 ではなく Ubuntuをインストール→再起動後、Ubuntuの画面にてInstaling, this may take a few minutes... と表示される。この文の次に下記エラーが表示された。
WslResisterDistribution failed with error: 0x80370110
・Ubuntuのアンインストールを実行しようとしたが、Windowsの設定→アプリと機能 にて Ubuntu が見つからなかったので、別の方法を試した。
・Windows Terminal にて wslconfig /l にて、現在WSLに登録されているディストリビューションを調べて、そのバージョンをアンインストールする。確か wslconfig /u Ubuntu と実行した気がする(うろ覚え)
・アンインストールが正常に終了したら、Ubuntu 22.04 をMicrosoft Store から「入手」する

Windows Terminal とWSL2の起動方法

Windowsキー押下→wtを入力→Windows Terminalを実行

Ubuntuの再起動方法

Windows再起動後にUbuntu22.04の起動方法がわあらなかったので調べた。
Windows Terminalを起動して wsl コマンドを実行してみたら、インストールしたときと明らかに違うUbuntuが起動して焦った。だってls コマンドの実行結果が前回と違ったんだもの。
誰だお前?!.png

Windows Terminal を右クリックして、インストールしたUbuntuを選択したら、ちゃんと前回のが開いた。よかったよかった。
Linux再起動方法.png

参考

Windows 10でWSL 2を有効化する方法
Windows Subsystem for Linux(WSL)をインターネット接続のないオフライン環境にインストールする → 「指定されたパスが見つかりません」と出たら wslconfig.exe /l してから /u でアンインストールして解決

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?