本記事では、Windows 11/10で利用できるWSL2 (Windows Subsystem for Linux) 環境でUbuntuデスクトップ環境を実現する方法をご紹介致します。

本記事の読者層は以下の方を想定しています。
- Windows 10のWSL2環境でUbuntuデスクトップ環境を構築したい方
Ubuntuデスクトップ環境を構築するということ
まだWindowsにWSL2をインストールしていない、という方は、こちらを参考にWSL2とUbuntu 20.04をインストールしてください。


不安な場合は、Windows10のPowerShell上でWSL2がインストールされているかは以下でコマンドで確認出来ます。
PS C:\Users\users> wsl --list --verbose
NAME STATE VERSION
* Ubuntu-18.04 Running 2
Ubuntu-20.04 Running 2
上記は、Ubuntu 18.04と20.04がインストールされている環境ですが「VERSION」がとなっていればWSL2がインストールされている環境ですので安心して下さい。
GUI環境を表示する先として、Windows側にXサーバーをインストールします。今回は、XサーバーソフトとしてVcXsrvを使用します。
インストール前の準備
Ubuntuのアップデート(ディストリビューションの更新)を行います。
$ sudo apt-get update
$ sudo apt-get upgrade
Ubuntuデスクトップ環境のインストール
以下の二つのコマンドを入力します。
$ sudo apt-get install libgl1-mesa-dev xorg-dev xbitmaps x11-apps
$ sudo apt-get install ubuntu-desktop
ここまではエラーもなく進めます。ただ、「sudo apt-get install ubuntu-desktop」を入れるのにはそれなり時間がかかります。
LinuxサーバーとWindows11を繋ぐ
このままでは、Windows11での実際利用できません。
VcXsrvのインストール(Windows 10ユーザーのみ)
以下の操作はX11を利用するだけであればインストールしなくても問題ないです。
https://sourceforge.net/projects/vcxsrv/




にてインストールを選択する。


終了です。
XLaunchの起動






$ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
$ sudo service x11-common start
$ sudo service dbus start
$ gnome-shell --x11 -r
(gnome-shell:16498): mutter-WARNING **: 15:07:07.333: Failed to create backend: Unable to open display ‘8.8.8.8:0.0’
WSL2+X11環境の実現
以下のX11環境を構築することで、Windows上でX11アプリを起動することができます。


代表的なLinuxアプリの紹介
X11アプリ
(1) XLogo
$ xcalc
(2) gnuplot
$ sudo apt-get install gunplot
$ gnuplot
(3) xeyes
$ xeyes
(4) xcalc
$ xcalc
(5) xterm
$ apt-get install xterm
$ xterm
(6) xclock
$ xclock
(7) glxgears
$ sudo apt-get install mesa-utils
$ glxgears
さらに充実させるための方法
さらにWindows11でUbuntu環境を実現したい場合は以下が参考になります。


まとめ
本記事では、Windows 11のWSL2環境でUbuntuデスクトップ環境を構築する方法を学びました。
次回の記事をご期待下さい。どうぞよろしくお願いいたします。
関連リンク








コメント