Windows Subsystem for Linux
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.
Bash running on Windows 10 | |
Other names | WSL |
---|---|
Developer(s) | Microsoft |
Initial release | August 2, 2016 |
Stable release | WSL 2
/ June 12, 2019[1] |
Repository | github |
Operating system | Microsoft Windows |
Predecessor | Windows Services for UNIX |
Type | Compatibility layer, Virtualization |
Website | blogs |
In May 2019, WSL 2 was announced,[2] introducing important changes such as a real Linux kernel,[3] through a subset of Hyper-V features. Since June 2019, WSL 2 is available to the Windows 10 customers through the Windows Insider program, including the Home edition.[4]
Overview
The first release of WSL provides a Linux-compatible kernel interface developed by Microsoft, containing no Linux kernel code,[5] which can then run a GNU user space on top of it, such as that of Ubuntu,[6][7][8][9] openSUSE,[10] SUSE Linux Enterprise Server,[11][12][13] Debian[14] and Kali Linux.[15] Such a user space might contain a Bash shell and command language, with native GNU command-line tools (sed, awk, etc.), programming-language interpreters (Ruby, Python, etc.), and even graphical applications (using an X11 server at the host side).[16]
The architecture was redesigned in WSL 2,[2] with a Linux kernel running in a lightweight virtual machine environment.
Introduction and availability
When introduced with the Anniversary Update on August 2, 2016, only an Ubuntu image was available. The Fall Creators Update, released on October 17, 2017, moved the installation process for Linux distributions to the Windows Store, and introduced SUSE images.[13]
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 6, 2019,[2] which features a completely new VM-based backend (based on a subset of Hyper-V features) in lieu of the prior system-call adaptation layer, planned for release through the Windows Insider program in June 2019.
Development
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.[17] It was first made available in Windows 10 Insider Preview build 14316.[18]
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.[19]
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.[20] 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.[3]
Microsoft envisages WSL as "primarily a tool for developers – especially web developers and those who work on or with open source projects".[16] In September 2018, Microsoft said that "WSL requires fewer resources (CPU, memory, and storage) than a full virtual machine" (which prior to WSL was 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.[16]
Architecture
WSL 1
LXSS Manager Service
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.[21]
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.
wsl.exe
Developer(s) | Microsoft |
---|---|
Initial release | August 2, 2016 |
Operating system | Microsoft Windows |
Type | Command |
Website | blogs |
The wsl.exe
command is used to manage distributions in the Windows Subsystem for Linux on the command-line. It can list available distributions, set a default distribution, and uninstall distributions.[22] The command can also be used to run Linux binaries from the Windows Command Prompt or Windows PowerShell.[23] wsl.exe
replaces lxrun.exe
which is deprecated as of Windows 10 1803 and later.[24]
Examples
Run uname
command in WSL using PowerShell.
PS C:\temp> wsl uname --all
Linux WikiMachine 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
Example using sudo
command from Command Prompt.
C:\temp> wsl sudo apt-get update
[sudo] password for username:
Hit:1 https://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 https://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Hardware and filesystem access
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
)[25] 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.[26]
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.[16]
Limitations
WSL 1 is not capable of running all Linux software, such as 32-bit binaries,[27][28] 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),[29] 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.[30][31]
Microsoft stated WSL was designed for the development of applications, and not for desktop computers or production servers, recommending the use of virtual machines (Hyper-V), Kubernetes and Azure for those purposes.[16]
Benchmarks
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.[32][33][34] 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.[3]
WSL 2
Version 2 introduces changes in the architecture. Microsoft has opted for virtualization through a highly optimized subset of Hyper-V features, in order to run its provided kernel and the underlying distributions, promising performance equivalent to WSL 1. For backward compatibility, developers don't need to change anything in their published distributions. WSL2 settings can be tweaked by the WSL global configuration, contained in an INI file named .wslconfig
in the User Profile folder.[35][36]
The distribution installation resides inside an ext4-formatted filesystem inside a virtual disk, and the host file system is transparently accessible through the 9P protocol,[37] similarly to other virtual machine technologies like QEMU.[38] For the users, Microsoft promised up to 20 times the read/write performance of WSL 1.[39] From Windows an IFS network redirector is provided for Linux guest file access using the UNC path prefix of \\wsl$
.
WSL 2 requires Windows build 19041 or higher.[40]
Screenshots
Controversy
There are fears in the developer community that Windows Subsystem for Linux could be a way to embrace, extend, and extinguish Linux.[41][42]
Richard Stallman has expressed fears that integrating Linux functionality into Windows will only hinder the development of open source software.[43]
“The aim of the free software movement is to free users from freedom-denying proprietary programs and systems, such as Windows. Making a non-free system, such as Windows or MacOS or iOS or ChromeOS or Android, more convenient is a step backward in the campaign for freedom.”
See also
References
- Craig Loewen (12 June 2019). "WSL 2 is now available in Windows Insiders". Windows Command Line.
- Craig Loewen (6 May 2019). "Announcing WSL 2". Windows Command Line Tools For Developers.
- mscraigloewen. "About WSL 2". docs.microsoft.com.
- "WSL 2 Post BUILD FAQ". Windows Command Line Tools For Developers. 14 May 2019.
- Gerwitz, Mike. "GNU/kWindows". mikegerwitz.com. Retrieved 8 April 2018.
- Harsh, Mike (30 March 2016). "Run Bash on Ubuntu on Windows". Building Apps for Windows. Microsoft.
- Finley, Klint (30 March 2016). "Why Microsoft Making Linux Apps Run on Windows Isn't Crazy". Wired. Condé Nast.
- Kirkland, Dustin (30 March 2016). "Ubuntu on Windows – The Ubuntu Userspace for Windows Developers". Ubuntu Insights. Canonical.
- Hammons, Jack (9 April 2016). "Bash on Ubuntu on Windows". MSDN. Microsoft.
- Get openSUSE Leap 42 - Microsoft Store
- Get SUSE Linux Enterprise Server 12 - Microsoft Store
- Yegulalp, Serdar (12 May 2017). "Windows Subsystem for Linux welcomes Suse and Fedora options". InfoWorld. Retrieved 16 September 2017.
- "Ubuntu now available from the Windows Store!". Windows Command Line Tools For Developers Blog. 10 July 2017. Retrieved 11 August 2017.
- "Debian GNU/Linux for WSL now available in the Windows Store". Windows Command Line Tools For Developers. Retrieved 7 March 2018.
- "Kali Linux in the Windows App Store". Retrieved 9 March 2018.
- "Frequently Asked Questions for WSL". Microsoft. Retrieved 13 November 2016.
- Bright, Peter (6 April 2016). "Why Microsoft needed to make Windows run Linux software". Ars Technica. Condé Nast.
- Aul, Gabe (6 April 2016). "Announcing Windows 10 Insider Preview Build 14316". Windows Experience Blog. Microsoft.
- "Windows Subsystem for Linux Overview". Windows Subsystem for Linux. Retrieved 22 April 2018.
- Microsoft Ignite (2 October 2018), OS internals: Technical deep-dive into operating system innovations - BRK3365, retrieved 7 May 2019
- Jack Hammons (22 April 2016). "Windows Subsystem for Linux Overview". Windows Subsystem for Linux blog on MSDN.
- Manage and configure Windows Subsystem for Linux
- Windows Subsystem for Linux interoperability with Windows
- Command Reference for Windows Subsystem for Linux
- Jack Hammons (15 June 2016). "WSL File System Support". Windows Subsystem for Linux blog on MSDN.
- Jack Hammons (8 November 2016). "WSL Networking". Windows Subsystem for Linux blog on MSDN.
- "Please enable WSL to run 32 bit ELF binaries". Windows Developer feedback (Microsoft/UserVoice).
- "Support for 32-bit i386 ELF binaries". GitHub.
- "Windows 10's Bash shell can run graphical Linux applications with this trick". PC World. Retrieved 10 September 2018.
- "GPU not accesssible for running tensorflow and installing CUDA · Issue #1788 · Microsoft/WSL". GitHub. Retrieved 10 September 2018.
- "OpenCL & CUDA GPU support". Windows Developer feedback (Microsoft/UserVoice). 15 September 2016. Retrieved 10 September 2018.
- "Windows Subsystem for Linux". Phoronix.
- Michael Larabel (12 October 2018). "A Look At The Windows 10 October 2018 Update Performance With WSL". Phoronix.
- Michael Larabel (5 November 2018). "The WSL Improvements In The Windows 10 October 2018 Update". Phoronix.
- Loewen, Craig (26 July 2019). "What's new for WSL in Insiders Preview Build 18945". Microsoft devblog. Archived from the original on 26 July 2019. Retrieved 26 July 2019.
In this new update we’ve added the ability to start using global config options for WSL. These options are targeted towards power users who want to further customize their WSL experience.
- Hillis, Ben (25 July 2019). "MicrosoftDocs/WSL | Build 18947". GitHub. Archived from the original on 26 July 2019. Retrieved 26 July 2019.
- "A Deep Dive Into How WSL Allows Windows to Access Linux Files". Windows Command Line Tools For Developers. 30 May 2019. Retrieved 24 June 2019.
- Jujjuri, Venkateswararao; Van Hensbergen, Eric; Liguori, Anthony; Pulavarty, Badari (13–16 July 2010). "VirtFS—A virtualization aware File System pass-through" (PDF). Linux Symposium.
- "Announcing WSL 2". Windows Command Line Tools For Developers. 6 May 2019. Retrieved 24 June 2019.
- "Installation Instructions for WSL 2". Retrieved 7 May 2020.
- "Should We Worry Microsoft Will 'Embrace, Extend, and Extinguish' Linux?". Retrieved 7 March 2018.
- "Microsoft Announced Linux App GUI Support". Retrieved 20 May 2020.
- "Richard Stallman vs. Canonical's CEO: 'Will Microsoft Love Linux to Death?'". Retrieved 27 July 2020.
External links
Wikimedia Commons has media related to Windows Subsystem for Linux. |
- Windows Command Line blog
- WSL on Microsoft Docs
- WSL on GitHub
- WSL2-Linux-Kernel on GitHub
- Windows Command Line Tools For Developers blog
- Brown, Pete (22 July 2016). "Fun with the Windows Subsystem for Linux". Windows Developer Blog. Microsoft.