$30 off During Our Annual Pro Sale. View Details »

Windows Subsystem for Linux 2 と Visual Studio Code Remote (SSH|WSL)

Windows Subsystem for Linux 2 と Visual Studio Code Remote (SSH|WSL)

2020/8/14(Fri) 社内 LT 会で発表した内容です。

typewriter / takuya

August 14, 2020
Tweet

More Decks by typewriter / takuya

Other Decks in Technology

Transcript

  1. Windows
    S ubsystem for
    L inux
    2
    と Visual
    Studio
    Code Remote (SSH|WSL)
    2020/08/14 Takuya Yamaguchi / @no_clock (たいぷらいた~)

    View Slide

  2. たいぷらいた~ @no_clock
    すき: 京都、百合
    京都行きたい…
    直近の新刊情報:
    8/7 不揃いの連理 (3)
    8/12 おとなになっても (3)
    8/21 塔子さんは
    家事ができない。 (1)
    8/24 ふたりべや (8)
    8/27 ゆゆ式 (11)
    新米姉妹のふたりごはん (8)
    ※何を「百合」とするかは個人差があります
    正伝寺(京都市北区) 2015/8/27 撮影

    View Slide

  3. Windows Subsystem for Linux 2 ...
    どうして Windows の話?

    View Slide

  4. Catalina で HDMI 出力が不調… → Ubuntu へ
    ● Mac mini を macOS Catalina に更新後、セカンドディスプレイが映らず
    ● Apple Community や各所で同様の報告
    ● 自作 PC では映る (Windows / Ubuntu)
     →よっしゃ Ubuntu 使ったろ!
    https://discussions.apple.com/thread/250715830 No HDMI signal after update - Apple Community

    View Slide

  5. ● 動くけど動かない、徐々に削られていく心の余裕
    ● おとなしく Windows 10 に戻る
    Ubuntu 、楽しいけど厳しい → Windows へ
    https://twitter.com/no_clock/status/1275092243632680960

    View Slide

  6. The Go gopher: Renee French (CC-BY 3.0)
    TypeScript: Microsoft (CC-BY 4.0)
    Windows で
    Golang や Ruby や TypeScript を書きたい…
    WSL2 と VSCode Remote (SSH|WSL) が
    良いらしいので使ってみるか…?

    View Slide

  7. Windows Subsystem for Linux
    開発者は、従来の仮想マシンまたはデュアルブート セットアップのオー
    バーヘッドなしで、ほとんどのコマンド ライン ツール、ユーティリティ、ア
    プリケーションを含む GNU/Linux 環境を変更せずそのまま
    Windows 上で直接実行できます。
    https://docs.microsoft.com/ja-jp/windows/wsl/about Linux 用 Windows サブシステムについて | Microsoft Docs

    View Slide

  8. 2020/05
    Windows Subsystem for Linux
    1 → 2

    View Slide

  9. Windows Subsystem for Linux 1
    “Pico provider drivers (lxss.sys, lxcore.sys) that emulate a Linux
    kernel by translating Linux syscalls”
    https://www.youtube.com/watch?v=lwhMThePdIo The new Windows subsystem for Linux architecture: a deep dive - BRK3068 - YouTube
    https://docs.microsoft.com/ja-jp/archive/blogs/wsl/windows-subsystem-for-linux-overview Windows Subsystem for Linux Overview | Microsoft Docs

    View Slide

  10. Windows Subsystem for Linux 2
    https://www.youtube.com/watch?v=lwhMThePdIo The new Windows subsystem for Linux architecture: a deep dive - BRK3068 - YouTube

    View Slide

  11. Windows Subsystem for Linux 2
    https://docs.microsoft.com/ja-jp/windows/wsl/compare-versions WSL 2 と WSL 1 の比較 | Microsoft Docs
    Feature WSL 1 WSL 2
    Integration between Windows and Linux ✅ ✅
    Fast boot times ✅ ✅
    Small resource foot print ✅ ✅
    Runs with current versions of VMWare and
    VirtualBox
    ✅ ✅
    Managed VM ❌ ✅
    Full Linux Kernel ❌ ✅
    Full system call compatibility ❌ ✅
    Performance across OS file systems ✅ ❌

    View Slide

  12. Windows Subsystem for Linux 2
    Integration between
    Windows and Linux
    ● ターミナルを起動
    するだけで Linux
    ● Windows 側は
    /mnt/ で
    読み書き可能

    View Slide

  13. Docker も公式の (Linux 向け) インストール手順でぺろっと動く
    Windows Subsystem for Linux 2

    View Slide

  14. Windows Subsystem for Linux 2
    Ubuntu 20.04 が
    そのまま動いている
    なお Ubuntu 20.04 は
    Microsoft Store から
    インストールする
    Microsoft Store の
    数少ない活用事例

    View Slide

  15. Terminal
    conhost.exe (コンソール ウィンドウ ホスト)
    ● コマンドプロンプトや PowerShell 等のガワ
    ● 操作性はお察し
    Windows Terminal
    ● 2020/05 バージョン 1.0 リリース
    ● タブ、分割、範囲選択、右クリック貼り付け
    ● 普通に使えるターミナル
    ● Microsoft Store から導入 数少ない活用事例

    View Slide

  16. Visual
    Studio
    Code
    Remote (SSH|WSL)

    View Slide

  17. Visual
    Studio
    Code
    Remote (SSH|WSL)
    リモートのコードを
    VSCode で編集できる
    拡張機能
    ← SSH ログインから
    Go 拡張機能含め
    いい感じに
    動作している様子

    View Slide

  18. Visual
    Studio
    Code
    Remote (SSH|WSL)
    ● リモートに VSCode Server が立っている
    https://code.visualstudio.com/docs/remote/ssh Developing on Remote Machines using SSH and Visual Studio Code

    View Slide

  19. Visual
    Studio
    Code
    Remote (SSH|WSL)
    ● リモートに VSCode Server が立っている
    ○ Go などの Workspace Extension はリモートで動作
    (環境毎にインストールが必要)

    View Slide

  20. The Neovim logo by Jason Long (CC-BY 3.0)
    構成
    Visual Studio Code
    Windows Terminal
    VSCode Server Golang tools
    Docker
    Neovim

    View Slide

  21. 雑感: 結構いけるぞ…! CUI は…!
    ● WSL2
    ○ 速 (Windows 起動直後で 5 秒、以降は 1 秒)
    ○ VM にあった煩わしさがほぼない
    ■ ISO ダウンロード、インストール、起動、停止、
    CPU やメモリ割当、性能劣化、ファイル共有…
    ■ ただしディスクイメージはある (可変サイズ)

    View Slide

  22. 雑感: 結構いけるぞ…! CUI は…!
    ● WSL2
    ○ GUI は
    鋭意対応中
    https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/ The Windows Subsystem for Linux BUILD 2020 Summary | Windows Command Line

    View Slide

  23. ● WSL 1→2
    ○ Windows Terminal がまともで実用的
    ■ WSL1 の頃、 conhost.exe がイマイチだが
    他にしっくりくるターミナルも見つからず、
    sshd 入れて PuTTY (ssh client) を使った時期も…
    ○ Docker もばっちり動く Full Linux Kernel
    雑感: 結構いけるぞ…! CUI は…!

    View Slide

  24. 雑感: 初期設定さえ済めばいける…!
    ● VSCode Remote (SSH|WSL)
    ○ WSL2 との組み合わせは便利
    ○ Extension をリモートに入れるのは手間
    ■ まずリモートに (go|ruby) をインストールして…
    ■ .bash_profile 等は読まないので…
    VSCode 上の設定でパスを絶対指定したり…
    ○ SSH 公開鍵認証では、秘密鍵がパーミッション 600 相当
    となるよう NTFS ACL (アクセス制御リスト) の設定が必要

    View Slide

  25. The Go gopher: Renee French (CC-BY 3.0)
    TypeScript: Microsoft (CC-BY 4.0)
    WSL2 と VSCode Remote (SSH|WSL) で
    現時点では なんとかなっている! すごい!
    ( 1 ヶ月ほど運用中)

    View Slide


  26. Linux 2.0 Penguins: [email protected] and The GIMP

    View Slide