目次
文書の過去の版を表示しています。
Windows Subsystem for Linux 2 (WSL 2)
ソースコード: GitHub - microsoft/WSL2-Linux-Kernel: The source for the Linux kernel used in Windows Subsystem for Linux 2 (WSL2)
Windows Subsystem for Linux 2 (以下 WSL 2) は、2019/05/06 にブログで発表され、2019年6月末までに Windows Insider Program を通じて Microsoft が Windows で Linux カーネルを出荷する試みである。Windows 10 Insider Previews も参照のこと。
Linux カーネルが Windows に同梱されるのは、今回が初である。(Microsoft は過去にも 2018 年に Microsoft Azure Sphere で Linux カーネル自体は出荷した事がある)
WSL 2 は Microsoft がパッチを当てた Linux カーネル (初期ビルドでは Linux Kernel Version 4.19 ベース) を lightweight utility virtual machine (軽量ユーティリティ仮想マシン) (以下 VM) 内で実行する。この Linux カーネルは WSL 2 専用に構築された小型で軽量な WSL 2 Linux カーネルである。
VM で実行する技術は KVM、VMware、VirtualBox、Xen、Hyper-V、Docker… など今までもたくさんあったが、どれも起動が遅く、非常に隔離された環境に存在し、多くのコンピューターリソースを消費し、それを管理する時間が必要なものであった。それに比べて WSL 2 が他の VM と異なる点は以下の通りである。
- Windows と Linux 間の高レベルの統合
- 非常に高速な起動時間 (2 秒以内に機能する bash シェルにアクセスできる)
- 小さなリソースフットプリント
- そして何よりも VM の構成や管理が不要
WSL は、Linux の ELF フォーマット形式のバイナリ実行ファイルを Windows でネイティブ実行できるようにするための互換レイヤーであるが、WSL 1 では一部で互換性の問題があったが、WSL 2 では Linux カーネルを Windows に内臓したことで完全なシステムコールの互換性を提供すると伴に、ファイルシステムのパフォーマンスが劇的に向上している。
インストール
参考文献
WSL 2 | Microsoft Docs
WSL 2 のインストール | Microsoft Docs
Announcing WSL 2 | Windows Command Line Tools For Developers
Shipping a Linux Kernel with Windows | Windows Command Line Tools For Developers
Windows Subsystem for Linux Overview – Windows Subsystem for Linux
トラブルシューティング
System has not been booted with systemd as init system (PID 1). が発生する
Systemd support for Windows Subsystem for Linux (WSL) · Issue #8036 · systemd/systemd · GitHub
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to create bus connection: Host is down
システムは、initd システム (PID 1) なので systemd として起動されていません。操作できません。
バスへの接続に失敗しました: ホストがダウンしています
本物の Fedora の PID 1 は /usr/lib/systemd/systemd であるが…
$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.5 171732 5500 ? Ss 9月05 2:13 /usr/lib/systemd/systemd --switched-root --system --deserialize 33 root 2 0.0 0.0 0 0 ? S 9月05 0:00 [kthreadd] ...
現状の WSL 2 では PID 1 は /init である。
$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 888 560 ? Sl 10:55 0:00 /init root 6 0.0 0.0 896 80 ? Ss 10:55 0:00 /init ...