Successfully reported this slideshow.
Your SlideShare is downloading. ×

WSL - Windows SubSytem For Linux

Ad

twitter: @MithunShanbhag
blog: mithunshanbhag.github.io

Ad

twitter: @MithunShanbhagblog: mithunshanbhag.github.io

Ad

twitter: @MithunShanbhagblog: mithunshanbhag.github.io

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Loading in …3
×

Check these out next

1 of 37 Ad
1 of 37 Ad

WSL - Windows SubSytem For Linux

In this talk, we'll dive into WSL (Windows SubSystem For Linux). We'll look at the internals, tooling, tips/tricks/gotchas & upcoming roadmap for WSL2.

Author: Mithun Shanbhag

In this talk, we'll dive into WSL (Windows SubSystem For Linux). We'll look at the internals, tooling, tips/tricks/gotchas & upcoming roadmap for WSL2.

Author: Mithun Shanbhag

More Related Content

WSL - Windows SubSytem For Linux

  1. 1. twitter: @MithunShanbhag blog: mithunshanbhag.github.io
  2. 2. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  3. 3. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  4. 4. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  5. 5. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  6. 6. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  7. 7. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  8. 8. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  9. 9. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  10. 10. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  11. 11. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  12. 12. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  13. 13. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  14. 14. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  15. 15. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  16. 16. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  17. 17. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  18. 18. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Documentation)
  19. 19. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Documentation)
  20. 20. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  21. 21. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  22. 22. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  23. 23. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Blog)
  24. 24. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Blog)
  25. 25. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Blog)
  26. 26. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Blog)
  27. 27. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (WSL Blog)
  28. 28. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  29. 29. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  30. 30. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  31. 31. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  32. 32. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  33. 33. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Build 2019)
  34. 34. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (VSCode Documentation)
  35. 35. twitter: @MithunShanbhagblog: mithunshanbhag.github.io Image attribution: Microsoft (Docker Documentation)
  36. 36. twitter: @MithunShanbhagblog: mithunshanbhag.github.io
  37. 37. twitter: @MithunShanbhagblog: mithunshanbhag.github.io

Editor's Notes

  • WSL is mainly for development scenarios. NOT for production scenarios.

    Major adv is Windows <-> Linux interop
  • 1. WSL2 requires windows insider build 18917 or higher.

    2. You can install multiple linux distros (only one will be default).

    2. Can be installed in one of the following ways:
    Download & install from Microsoft store.
    Download & install APPX.

    2. Installation on Win Server has additional steps (unzip appx file & run installer).
  • 7. Run “ls -l /usr/bin/wsl*“ to see list of wsl utilities
    wslsys
    wslfetch –splash (takes a bit of time)
    wslvar –getsys

    8. Run “sudo /etc/init.d/docker start” to start docker
    Docker ps
    Docker images
    Docker run –it alpine /bin/sh
  • 1. WSL2 requires windows insider build 18917 or higher.

    2. You can install multiple linux distros (only one will be default).

    2. Can be installed in one of the following ways:
    Download & install from Microsoft store.
    Download & install APPX.

    2. Installation on Win Server has additional steps (unzip appx file & run installer).
  • @todo: Show examples with “--set-version” and “--unregister”.
  • 1. The \\WSL$ is facilitated by 9P server (running inside /init)
  • 5.1. To clarify:
    - If linux command prompt is under /mnt/xyz, then the windows command gets the same as its current directory.
    - If linux command prompt is elsewhere, then the windows command gets %WINDIR% as its current directory.
  • - /etc/fstab is processed on WSL start. /etc/fstab is a file where you can declare other filesystems, like an SMB share. Thus, you can mount these filesystems automatically in WSL on start up.
    - /etc/hosts file, contains hostname <-> ip mapping
    - /etc/resolv.conf file, contains list of DNS resolution servers
  • 1.2. Not really a limitation. More like a blessing.
    3.1. We’ll explore more in detail in WSL2 architecture.
  • @todo: wslpath
  • NTDLL, PEB, TEB etc are the standard interfaces between user-mode processes and the NT kernel.

    3. Pico processes do not interact with NT Kernel directly.
    3. When NT Kernel detect a process without PEB/TEB/NTDLL, it asks LXSS/LXCore to interact with it instead.

    3. @todo: The pico providers (LXSS/LXCore) provide POSIX compliance for NT Kernel?
  • 1. VFS abstracts all file system operations.

    1. Various ile systems are mounted on different directories in the VFS namespace.
     
    1. VFS utilizes a number of data structures
    - inodes
    - directory entries
    - file objects
    - file descriptors,
    - special files (device files, FIFOs, sockets, symbolic links).
  • 2. The first time an NT process requests launching a Linux binary an instance is created. Once the last NT client closes, the Linux instance is terminated.


    Notes on /init:
    /init is a multi-purpose binary that was written by Microsoft and is shipped as a binary resource contained in LxssManager.dll.
    When /init is launched, it first checks its PID.
    If the PID is 1, /init will run in "daemon mode" where it essentially the Lxss Manger service’s endpoint inside a WSL instance.
    If the PID is not 1, /init runs as "binfmt_misc interpreter mode" which allows launching NT binaries.
  • Advantages of WSL2 over WSL
    - Faster file access
    - Full kernel implementation

    7. Key thing to remember is that linux is running side-by-side with windows (and not inside it).
  • 4. The EXT4 VHD is mapped in. Then the /init process is run.
  • Important to note that:
    In WSL1, both Windows & Linux were running on same machine.
    In WSL2, they are running in “separate” machines.

    The P9 server facilitates Windows <-> Linux file sharing.

    - In the scenario above, P9 allows Linux VM access to windows file share
  • 9P facilitates \\WSL$ share
  • P9 here facilitates mounting of windows file share
  • Single linux kernel serves multiple distros

×