| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「WSL」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
 
(同じ利用者による、間の2版が非表示)
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 以上

2022年3月20日 (日) 03:33時点における最新版

|スクリプト(Win) | シェルプログラミング

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 を参照してください
  1. 最新カーネルのダウンロード1

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
$ sudo service docker start 
$ minikube start --vm-driver=docker

Wsl kubernetes.png

  • 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"}