windows里面的Linux内核 WSL

什么是Windows Subsystem for Linux

WSL(Windows Subsystem for Linux) 是win10的新特性,能够让以跑Linux原生的命令行

WSL的设计原理

共享comm系统

共享文件系统

启动/bin/bash
windows里面的Linux内核 WSL

  1. bash.exe uses the internal CreateLxProcess COM API to talk to the LXSS Manager service.
  2. The LXSS Manager service translates the current working directory to a WSL path and marshals NT handles provided by bash.exe representing StandardInput, StandardOutput, StandardError, and the console with LxCore.sys.
  3. The LXSS Manager sends a message via LxBus to our custom /init daemon.
  4. The init daemon parses the message and unmarshals StandardInput, StandardOutput, StandardError, and the console; setting them to file descriptors 0, 1, and 2 and creating a tty file descriptor.
  5. /init forks and execs the /bin/bash binary and goes back to listen for the next create process message.

Launching an NT binary from within a WSL instance

  1. /bin/bash forks and execs an NT binary. LxCore.sys finds a binfmt_misc registration that handles Windows PE images and invokes the interpreter (/init).
  2. /init (running as the binfmt_misc interpreter) translates the current working directory and marshals file descriptors 0, 1, and 2 (representing stdin, stdout, and stderr) with LxCore.sys.
  3. /init sends a create NT process message to bash.exe.
  4. Bash.exe unmarshals the file descriptors, which creates NT handles, and calls CreateProcess specifying the NT handles as StandardInput, StandardOutput, and StandardError.

为什么不用CYGWIN之类的工具 而用WSL?

  • 这类工具总是假设能够访问长路径,或者访问一些特定的文件、文件夹,然而windows不是这样表现的
  • 一些原生的GEM库不支持windows,使得在windows上面的表现非常的不稳定。

可以在WSL上跑所有的linux app么?

不能,wsl是为那些想用bash和核心linux core的人做的

但是像是python是被包括在内的。

为啥跑APT-GET UPGRADE的时候有这么的ERRORS?

因为有些包不支持,比如udev