「WSL」の版間の差分
ナビゲーションに移動
検索に移動
| (同じ利用者による、間の24版が非表示) | |||
| 1行目: | 1行目: | ||
| + | |[[スクリプト(Win)]] | [[シェルプログラミング]] | ||
==WSL== | ==WSL== | ||
*https://docs.microsoft.com/ja-jp/windows/wsl/install-win10 | *https://docs.microsoft.com/ja-jp/windows/wsl/install-win10 | ||
| 7行目: | 8行目: | ||
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | ||
</pre> | </pre> | ||
| + | |||
| + | ===CMD.EXEと組み合わせて利用する=== | ||
| + | <pre> | ||
| + | C:\Users\piroto>dir | wsl -- grep 'm' | ||
| + | Volume in drive C has no label. | ||
| + | Volume Serial Number is 06DD-9634 | ||
| + | 2022/02/03 23:45 <DIR> .templateengine | ||
| + | 2022/02/03 22:19 <DIR> Documents | ||
| + | 2021/10/22 00:38 <DIR> Saved Games | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | C:\Users\piroto\Documents>wsl -- ls -al | ||
| + | total 0 | ||
| + | drwxrwxrwx 1 piroto piroto 4096 Feb 3 22:19 . | ||
| + | drwxrwxrwx 1 piroto piroto 4096 Feb 3 22:55 .. | ||
| + | -rwxrwxrwx 1 piroto piroto 0 Oct 28 19:42 Default.rdp | ||
| + | drwxrwxrwx 1 piroto piroto 4096 Feb 3 17:54 IISExpress | ||
| + | lrwxrwxrwx 1 piroto piroto 25 Oct 22 00:37 'My Music' -> /mnt/c/Users/piroto/Music | ||
| + | lrwxrwxrwx 1 piroto piroto 28 Oct 22 00:37 'My Pictures' -> /mnt/c/Users/piroto/Pictures | ||
| + | lrwxrwxrwx 1 piroto piroto 26 Oct 22 00:37 'My Videos' -> /mnt/c/Users/piroto/Videos | ||
| + | drwxrwxrwx 1 piroto piroto 4096 Feb 3 17:54 'My Web Sites' | ||
| + | drwxrwxrwx 1 piroto piroto 4096 Feb 3 23:12 'Visual Studio 2022' | ||
| + | -rwxrwxrwx 1 piroto piroto 402 Oct 22 00:38 desktop.ini | ||
| + | </pre> | ||
| + | |||
===WSL2に更新=== | ===WSL2に更新=== | ||
*x64 システムの場合:バージョン 1903 以降、ビルド 18362 以上 | *x64 システムの場合:バージョン 1903 以降、ビルド 18362 以上 | ||
| 14行目: | 41行目: | ||
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | ||
</pre> | </pre> | ||
| + | |||
| + | *仮想マシン機能を無効に | ||
| + | <pre> | ||
| + | dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /all /norestart | ||
| + | </pre> | ||
| + | |||
====カーネル更新パッケージのダウンロードと実行==== | ====カーネル更新パッケージのダウンロードと実行==== | ||
| − | *https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi | + | *SL 2 を実行するには、カーネル コンポーネントの更新が必要です。詳細については https://aka.ms/wsl2kernel を参照してください |
| + | *WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください | ||
| + | |||
| + | #[https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi 最新カーネルのダウンロード1] | ||
| + | ====WSL2を既定のバージョンとする1==== | ||
| + | <pre> | ||
| + | wsl --set-default-version 2 | ||
| + | </pre> | ||
| + | *[https://www.microsoft.com/ja-jp/software-download/windows10 --set-default-version が指定できない場合、Windows10 を update] | ||
| + | |||
| + | ====Linuxディストリビューションの選択==== | ||
| + | *[https://aka.ms/wslstore Microsoft Storeからインストール] | ||
| + | ====トラブルシュート==== | ||
| + | *https://docs.microsoft.com/ja-jp/windows/wsl/troubleshooting | ||
| + | ==管理== | ||
| + | ===WSLのファイルをエクスプローラーに表示=== | ||
| + | <pre> | ||
| + | \\wsl$ | ||
| + | </pre> | ||
| + | ===WindowsのCドライブをWSLから参照=== | ||
| + | <pre> | ||
| + | /mnt/c | ||
| + | </pre> | ||
| + | ==[[Kubernetes]]/[[Docker]]== | ||
| + | ===install [[Ubuntu]]=== | ||
| + | *https://docs.docker.com/engine/install/ubuntu/ | ||
| + | <pre> | ||
| + | $ sudo apt-get update | ||
| + | $ sudo apt-get install \ | ||
| + | apt-transport-https \ | ||
| + | ca-certificates \ | ||
| + | curl \ | ||
| + | gnupg-agent \ | ||
| + | software-properties-common | ||
| + | $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
| + | </pre> | ||
| + | *フィンガープリントの確認 | ||
| + | <pre> | ||
| + | $ sudo apt-key fingerprint 0EBFCD88 | ||
| + | pub rsa4096 2017-02-22 [SCEA] | ||
| + | 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | ||
| + | uid [ unknown] Docker Release (CE deb) <docker@docker.com> | ||
| + | sub rsa4096 2017-02-22 [S] | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | $ sudo add-apt-repository \ | ||
| + | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | ||
| + | $(lsb_release -cs) \ | ||
| + | stable" | ||
| + | </pre> | ||
| + | *Dockerエンジンのインストール | ||
| + | <pre> | ||
| + | $ sudo apt-get update | ||
| + | $ sudo apt-get install docker-ce docker-ce-cli containerd.io | ||
| + | </pre> | ||
| + | *[[Kubernetes|minikube のインストール]] | ||
| + | <pre> | ||
| + | $ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | ||
| + | $ sudo chmod +x minikube | ||
| + | $ sudo install minikube /usr/local/bin | ||
| + | </pre> | ||
| + | |||
| + | ===Kubectlのインストール=== | ||
| + | <pre> | ||
| + | $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | ||
| + | $ sudo chmod +x ./kubectl | ||
| + | $ sudo install kubectl /usr/local/bin | ||
| + | </pre> | ||
| + | ===起動=== | ||
| + | *ユーザーを[[Docker|docker]]グループに追加 | ||
| + | <pre> | ||
| + | $ sudo usermod -aG docker $USER && newgrp docker | ||
| + | </pre> | ||
| + | *[[Docker]]の起動 | ||
| + | <pre> | ||
| + | $ sudo service docker start | ||
| + | </pre> | ||
| + | *[[Kubernetes|minikube]]の起動 | ||
| + | <pre> | ||
| + | $ minikube start --vm-driver=docker | ||
| + | </pre> | ||
| + | [[File:Wsl_kubernetes.png|600px]] | ||
| + | *Unhealthy がある | ||
| + | |||
| + | <pre> | ||
| + | piroto@buddha:/mnt/c/workspaces/kubernetes$ kubectl get componentstatuses | ||
| + | Warning: v1 ComponentStatus is deprecated in v1.19+ | ||
| + | NAME STATUS MESSAGE | ||
| + | ERROR | ||
| + | scheduler Unhealthy Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused | ||
| + | controller-manager Unhealthy Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused | ||
| + | etcd-0 Healthy {"health":"true"} | ||
| + | </pre> | ||
2022年3月20日 (日) 03:33時点における最新版
目次
WSL
Linux用Subシステムの有効化
- Powershellを管理者で実行し、以下
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
CMD.EXEと組み合わせて利用する
C:\Users\piroto>dir | wsl -- grep 'm' Volume in drive C has no label. Volume Serial Number is 06DD-9634 2022/02/03 23:45 <DIR> .templateengine 2022/02/03 22:19 <DIR> Documents 2021/10/22 00:38 <DIR> Saved Games
C:\Users\piroto\Documents>wsl -- ls -al total 0 drwxrwxrwx 1 piroto piroto 4096 Feb 3 22:19 . drwxrwxrwx 1 piroto piroto 4096 Feb 3 22:55 .. -rwxrwxrwx 1 piroto piroto 0 Oct 28 19:42 Default.rdp drwxrwxrwx 1 piroto piroto 4096 Feb 3 17:54 IISExpress lrwxrwxrwx 1 piroto piroto 25 Oct 22 00:37 'My Music' -> /mnt/c/Users/piroto/Music lrwxrwxrwx 1 piroto piroto 28 Oct 22 00:37 'My Pictures' -> /mnt/c/Users/piroto/Pictures lrwxrwxrwx 1 piroto piroto 26 Oct 22 00:37 'My Videos' -> /mnt/c/Users/piroto/Videos drwxrwxrwx 1 piroto piroto 4096 Feb 3 17:54 'My Web Sites' drwxrwxrwx 1 piroto piroto 4096 Feb 3 23:12 'Visual Studio 2022' -rwxrwxrwx 1 piroto piroto 402 Oct 22 00:38 desktop.ini
WSL2に更新
- x64 システムの場合:バージョン 1903 以降、ビルド 18362 以上
- 18362 より前のビルドは WSL 2 をサポートしていません
仮想マシン機能を有効に
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- 仮想マシン機能を無効に
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /all /norestart
カーネル更新パッケージのダウンロードと実行
- SL 2 を実行するには、カーネル コンポーネントの更新が必要です。詳細については https://aka.ms/wsl2kernel を参照してください
- WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください
WSL2を既定のバージョンとする1
wsl --set-default-version 2
Linuxディストリビューションの選択
トラブルシュート
管理
WSLのファイルをエクスプローラーに表示
\\wsl$
WindowsのCドライブをWSLから参照
/mnt/c
Kubernetes/Docker
install Ubuntu
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- フィンガープリントの確認
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
- Dockerエンジンのインストール
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 $ sudo chmod +x minikube $ sudo install minikube /usr/local/bin
Kubectlのインストール
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl $ sudo chmod +x ./kubectl $ sudo install kubectl /usr/local/bin
起動
- ユーザーをdockerグループに追加
$ sudo usermod -aG docker $USER && newgrp docker
- Dockerの起動
$ sudo service docker start
- minikubeの起動
$ minikube start --vm-driver=docker
- Unhealthy がある
piroto@buddha:/mnt/c/workspaces/kubernetes$ kubectl get componentstatuses
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME STATUS MESSAGE
ERROR
scheduler Unhealthy Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused
controller-manager Unhealthy Get "http://127.0.0.1:10252/healthz": dial tcp 127.0.0.1:10252: connect: connection refused
etcd-0 Healthy {"health":"true"}
© 2006 矢木浩人