はじめに
どうも仮想登山家初心者です. WSL2を試すノート.
WSL2
カーネル更新
公式を参照します.
https://docs.microsoft.com/ja-jp/windows/wsl/install-win10
おま環だと思うのですが, wsl_update_x64.msi
がダウンロードできないことがあります.
https://docs.microsoft.com/ja-jp/windows/wsl/wsl2-kernel
C:\Users\<UserName>\.wslconfig
[wsl2]
#kernel= # An absolute Windows path to a custom Linux kernel.
#memory=2GB # How much memory to assign to the WSL2 VM.
#processors=2 # How many processors to assign to the WSL2 VM.
#swap=0 # How much swap space to add to the WSL2 VM. 0 for no swap file.
#swapFile= # An absolute Windows path to the swap vhd.
#localhostForwarding= # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
# entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
# entries must be size followed by unit, for example 8GB or 512MB
Alpine
$ wsl --import [名前] [インストール先] [インストール元: alpine-minirootfs-xxx-x86_64.tar.gz] --version 2
使い方
$ wsl --help
$ wsl -l -v
$ wsl -d [名前] -u [ユーザー名]
最低限のアプリ
リポジトリ
http://dl-cdn.alpinelinux.org/alpine/vX.XX/main
http://dl-cdn.alpinelinux.org/alpine/vX.XX/community
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
$ adduser nya
$ addgroup nya wheel
$ apk update
$ apk upgrade
$ apk add sudo vim openssh
$ cp /etc/sudoers /etc/sudoers.tmp
$ sed -e 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g' /etc/sudoers.tmp | sed '$a Defaults timestamp_timeout = 60' > /etc/sudoers
SSH
$ ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
$ ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
$ ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
$ /usr/sbin/sshd
リソース制限
%USERPROFILE%\.wslconfig
[wsl2]
#kernel= # An absolute Windows path to a custom Linux kernel.
memory=2GB # How much memory to assign to the WSL2 VM.
processors=2 # How many processors to assign to the WSL2 VM.
swap=0 # How much swap space to add to the WSL2 VM. 0 for no swap file.
#swapFile= # An absolute Windows path to the swap vhd.
#localhostForwarding= # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
# entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
# entries must be size followed by unit, for example 8GB or 512MB
Windowsアプリ
/tools/initでWindows側で動いている.
Docker
$ apk add docker
$ dockerd&
X
VcXsrvを使用する.
xlaunch.exe -run config.xlaunch
$ apk add xfce4 thunar-volman faenza-icon-theme slim
$ startxfce4
$ apk add i3wm i3status
IPはホストのアドレスが安定する(おま環).
export DISPLAY=xxx.xxx.xxx.xxx:0.0
coTurn
https://github.com/coturn/coturn
$ sudo apk add linux-headers libevent-dev openssl-dev hiredis-dev
$ sudo apk add coturn
$ sudo cp /etc/coturn/turnserver.conf.default /etc/turnserver.conf
Troubleshooting
名前解決
/etc/wsl.conf
を作成して, resolv.confが自動で作成されないようにする.
[network]
generateResolvConf=false
/etc/resolv.conf
はリンクなので, 削除してからファイルを作成する.
$ sudo rm /etc/resolv.conf
$ sudo touch /etc/resolv.conf
/etc/resolv.conf
にサーバを追加する.
nameserver xxx.xxx.xxx.xx1
nameserver xxx.xxx.xxx.xx2
Windowsを再起動する, wsl.confが読まれるタイミングが不明, wsl --shutdown
ではだめ.