Windows Subsystem for Linux

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Windows Subsystem for Linux
Bash running on Windows 10
Bash running on Windows 10
Developer(s)Microsoft
Initial releaseAugust 2, 2016; 2 years ago (2016-08-02)
Operating systemMicrosoft Windows
ReplacesWindows Services for UNIX
TypeCompatibility layer, Virtualization
Websiteblogs.msdn.microsoft.com/wsl/

Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10 and Windows Server 2019.

Overview[edit]

WSL provides a Linux-compatible kernel interface developed by Microsoft (initially containing no Linux kernel code[1], which later changed with the redesigned architecture of WSL 2[2]) which can then run a GNU user space on top of it, such as that of Ubuntu,[3][4][5][6] openSUSE,[7] SUSE Linux Enterprise Server,[8][9][10] Debian[11] and Kali Linux.[12] Such a user space might contain a Bash shell and command language, with native GNU/Linux command-line tools (sed, awk, etc.), programming language interpreters (Ruby, Python, etc.), and even graphical applications (using a X11 server at the host side).[13]

Introduction and availability[edit]

When introduced with the Anniversary Update, only an Ubuntu image was available. The Fall Creators Update moved the installation process for Linux distributions to the Windows Store, and introduced SUSE images.[10]

WSL is available only in 64 bit versions of Windows 10 from version 1607. It is also available in Windows Server 2019.

Microsoft announced WSL 2 on May 6th, 2019[2], which features a completely new VM-based backend in lieu of the prior system call adaptation layer, planned for release through the Windows Insider program in June 2019.

Development[edit]

Microsoft's first foray into achieving Unix-like compatibility on Windows began with the Microsoft POSIX Subsystem, superseded by Windows Services for UNIX via MKS/Interix, which was eventually deprecated with the release of Windows 8.1. The technology behind Windows Subsystem for Linux originated in the unreleased Project Astoria, which enabled some Android applications to run on Windows 10 Mobile.[14] It was first made available in Windows 10 Insider Preview build 14316.[15]

Whereas Microsoft's previous projects and the third-party Cygwin had focused on creating their own unique Unix-like environments based on the POSIX standard, WSL aims for native Linux compatibility. Instead of wrapping non-native functionality into Win32 system calls as these prior systems utilized, WSL's initial design (WSL 1) leveraged the NT kernel executive to serve Linux programs as special, isolated minimal processes (known as "pico processes") attached to kernel mode "pico providers" as dedicated system call and exception handlers distinct from that of a vanilla NT process, opting to reutilize existing NT implementations wherever possible.[16]

Though WSL (via this initial design) was much faster and arguably much more popular than its brethren UNIX-on-Windows projects, Windows kernel engineers found difficulty in trying to increase WSL's performance and syscall compatibility by trying to reshape the existing NT kernel to recognize and operate correctly on Linux's API. At a Microsoft Ignite conference in 2018, Microsoft engineers gave a high-level overview of a new "lightweight" Hyper-V VM technology for containerization where a virtualized kernel could make direct use of NT primitives on the host.[17] In 2019, Microsoft announced a completely redesigned WSL architecture (WSL 2) using this lightweight VM technology hosting actual (customized) Linux kernel images, claiming full syscall compatibility.[2]

Microsoft envisages WSL as "primarily a tool for developers – especially web developers and those who work on or with open source projects".[13] WSL uses fewer resources than a typical virtual machine (prior to WSL the most direct way to run Linux software in a Windows environment), while also allowing users to use Windows apps and Linux tools on the same set of files.[13]

Architecture[edit]

LXSS Manager Service is the service in charge of interacting with the subsystem (through the drivers lxss.sys and lxcore.sys), and the way that Bash.exe (not to be confused with the Shells provided by the Linux distributions) launches the Linux processes, as well as handling the Linux system calls and the binary locks during their execution.[18]

All Linux processes invoked by a particular user go into a "Linux Instance" (usually, the first invoked process is init). Once all the applications are closed, the instance is closed.

Hardware and filesystem access[edit]

WSL 1's design featured no hardware emulation / virtualization (unlike other projects such as coLinux) and makes direct use of the host file system (through VolFS and DrvFS)[19] and some parts of the hardware, such as the network (web servers for example, can be accessed through the same interfaces and IP addresses configured on the host, and shares the same restrictions on the use of ports that require administrative permissions, or ports already occupied by other applications), which guarantees interoperability.[20]

There are certain locations (such as system folders) and configurations whose access/modification is restricted, even when running as root, with sudo from the shell. An instance with elevated privileges must be launched in order to get "sudo" to give real root privileges, and allow such access.[13]

Limitations[edit]

WSL 1 is not capable of running all Linux software, such as 32-bit binaries,[21][22] or those that require specific Linux kernel services not implemented in WSL. Due to a lack of any "real" Linux kernel in WSL 1, kernel modules, such as device drivers, can't be run. WSL 2, however, makes use of live virtualized Linux kernel instances.

It is possible to run some graphical (GUI) applications (such as Mozilla Firefox) by installing an X11 server within the Windows (host) environment (such as VcXsrv or Xming), [23] although not without caveats, such as the lack of audio support or hardware acceleration (resulting in poor graphics performance). Support for OpenCL and CUDA is also not being implemented currently, although planned for future releases.[24][25]

Microsoft stated WSL 1 as being oriented to the development of applications, and not for desktop environment or production servers, recommending the use of virtual machines (Hyper-V or Kubernetes) and Azure for those purposes.[13]

Benchmarks[edit]

In benchmarks WSL 1's performance is often near native Linux Ubuntu, Debian, Intel Clear Linux or other Linux distributions. I/O is in some tests a bottleneck for WSL.[26][27][28]. The redesigned WSL 2 backend is claimed by Microsoft to offer twenty-fold increases in speed on certain operations compared to that of WSL 1.[2]

Screenshots[edit]

See also[edit]

References[edit]

  1. ^ Gerwitz, Mike. "GNU/kWindows". mikegerwitz.com. Retrieved 8 April 2018.
  2. ^ a b c d "Announcing WSL 2". Windows Command Line Tools For Developers. 6 May 2019. Retrieved 7 May 2019.
  3. ^ Harsh, Mike (30 March 2016). "Run Bash on Ubuntu on Windows". Building Apps for Windows. Microsoft.
  4. ^ Finley, Klint (30 March 2016). "Why Microsoft Making Linux Apps Run on Windows Isn't Crazy". Wired. Condé Nast.
  5. ^ Kirkland, Dustin (30 March 2016). "Ubuntu on Windows – The Ubuntu Userspace for Windows Developers". Ubuntu Insights. Canonical.
  6. ^ Hammons, Jack (9 April 2016). "Bash on Ubuntu on Windows". MSDN. Microsoft.
  7. ^ Get openSUSE Leap 42 - Microsoft Store
  8. ^ Get SUSE Linux Enterprise Server 12 - Microsoft Store
  9. ^ Yegulalp, Serdar (12 May 2017). "Windows Subsystem for Linux welcomes Suse and Fedora options". InfoWorld. Retrieved 16 September 2017.
  10. ^ a b "Ubuntu now available from the Windows Store!". Windows Command Line Tools For Developers Blog. 10 July 2017. Retrieved 11 August 2017.
  11. ^ "Debian GNU/Linux for WSL now available in the Windows Store". Windows Command Line Tools For Developers. Retrieved 7 March 2018.
  12. ^ "Kali Linux in the Windows App Store". Retrieved 9 March 2018.
  13. ^ a b c d e "Frequently Asked Questions for WSL". Microsoft. Retrieved 13 November 2016.
  14. ^ Bright, Peter (6 April 2016). "Why Microsoft needed to make Windows run Linux software". Ars Technica. Condé Nast.
  15. ^ Aul, Gabe (6 April 2016). "Announcing Windows 10 Insider Preview Build 14316". Windows Experience Blog. Microsoft.
  16. ^ "Windows Subsystem for Linux Overview". Windows Subsystem for Linux. Retrieved 22 April 2018.
  17. ^ Microsoft Ignite (2 October 2018), OS internals: Technical deep-dive into operating system innovations - BRK3365, retrieved 7 May 2019
  18. ^ Jack Hammons (22 April 2016). "Windows Subsystem for Linux Overview". Windows Subsystem for Linux blog on MSDN.
  19. ^ Jack Hammons (15 June 2016). "WSL File System Support". Windows Subsystem for Linux blog on MSDN.
  20. ^ Jack Hammons (8 November 2016). "WSL Networking". Windows Subsystem for Linux blog on MSDN.
  21. ^ "Please enable WSL to run 32 bit ELF binaries". Windows Developer feedback (Microsoft/UserVoice).
  22. ^ "Support for 32-bit i386 ELF binaries". GitHub.
  23. ^ "Windows 10's Bash shell can run graphical Linux applications with this trick". PC World. Retrieved 10 September 2018.
  24. ^ "GPU not accesssible for running tensorflow and installing CUDA · Issue #1788 · Microsoft/WSL". GitHub. Retrieved 10 September 2018.
  25. ^ "OpenCL & CUDA GPU support". Windows Developer feedback (Microsoft/UserVoice). 15 September 2016. Retrieved 10 September 2018.
  26. ^ "Windows Subsystem for Linux". Phoronix.
  27. ^ Michael Larabel (12 October 2018). "A Look At The Windows 10 October 2018 Update Performance With WSL". Phoronix.
  28. ^ Michael Larabel (5 November 2018). "The WSL Improvements In The Windows 10 October 2018 Update". Phoronix.

External links[edit]