Windows11 に WSL(WSL2) Ubuntu 22.04 をインストール

概要

サブPCでWindows11を使い始めており、こちらにWSL Ubuntu 22.04をインストールしました。

現時点での私の環境は、Windows 11 Pro/バージョン 22H2/OSビルド 22621.2428 です。 現在の最新のWindows11では WSL のインストールは非常に簡単です。 Windows10 でも同じだと思われます(環境が無いため、私は試すことはできていません)。

手順

PowerShellを起動します。管理者権限ではなく、一般ユーザ権限で起動します。

インストール中に必要に応じて管理者権限が求められますのでそれに従います。

下記コマンドでインストール可能なディストリビューションが表示されます。

PS> wsl --list --online
インストールできる有効なディストリビューションの一覧を次に示します。
既定の分布は ' * ' で表されます。
 'wsl --install -d <Distro>'を使用してインストールします。

  NAME                                   FRIENDLY NAME
* Ubuntu                                 Ubuntu
  Debian                                 Debian GNU/Linux
  kali-linux                             Kali Linux Rolling
  Ubuntu-18.04                           Ubuntu 18.04 LTS
  Ubuntu-20.04                           Ubuntu 20.04 LTS
  Ubuntu-22.04                           Ubuntu 22.04 LTS
  OracleLinux_7_9                        Oracle Linux 7.9
  OracleLinux_8_7                        Oracle Linux 8.7
  OracleLinux_9_1                        Oracle Linux 9.1
  openSUSE-Leap-15.5                     openSUSE Leap 15.5
  SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
  SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
  openSUSE-Tumbleweed                    openSUSE Tumbleweed

下記のコマンドでインストールします。

PS> wsl --install -d Ubuntu-22.04
要求された操作には管理者特権が必要です。
インストール中: 仮想マシン プラットフォーム
仮想マシン プラットフォーム はインストールされました。
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。
インストール中: Ubuntu 22.04 LTS
Ubuntu 22.04 LTS はインストールされました。
要求された操作は正常に終了しました。変更を有効にするには、システムを再起動する必要があります。

上記の指示に従い、システムを再起動します。

再起動後、Windows Updateの処理が行われ、その後自動的に Ubuntu のシェルが起動します。

UNIX ユーザ名とパスワードを尋ねられますので、これを入力することでインストールが完了します。

Ubuntu 22.04 LTS を起動しています...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: wurly
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


This message is shown once a day. To disable it please create the
/home/wurly/.hushlogin file.
wurly@host:~$

本日時点で、wsl のバージョンは 1.2.5.0 でした。

PS> wsl --version
WSL バージョン: 1.2.5.0
カーネル バージョン: 5.15.90.1
WSLg バージョン: 1.0.51
MSRDC バージョン: 1.2.3770
Direct3D バージョン: 1.608.2-61064218
DXCore バージョン: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows バージョン: 10.0.22621.2428

PS> wsl --update
更新プログラムを確認しています。
Linux 用 Windows サブシステムの最新バージョンは既にインストールされています。

xclock をインストール、実行してみます。

$ sudo apt update
$ sudo apt install x11-apps
g$ xclock &

Linux 上の GUIアプリが立ち上がることが確認できました。

821_01.jpg

Copied title and URL