Javatpoint Logo
Javatpoint Logo

Ubuntu WSL

Introduction to WSL

WSL (short for Windows subsystem for Linux) is a compatibility layer to run Linux binary executables (inside ELF format) on Windows Server 2019, Windows 11, and Windows 10. WSL 2 was published in May 2019, introducing essential modifications like the Linux kernel from a Hyper V feature subset. It is available for the customers of Windows 10 from the Windows Insider program since June 2019 including the Home edition.

  • WSL isn't available for every user of Windows 10.
  • It could be installed either by manual install or by joining the program, i.e., Windows Insider.
  • The first version of WSL was published on 2 August 2016 and it provides a Linux-compatible interface of the kernel which is integrated by Microsoft.
  • The amazing fact is that it did not include real Linux kernel code. But it still supported almost all native commands of Linux.
  • The Microsoft team has established a translation layer between the NT kernel and user inputs.

It will be precisely passed down to the Windows kernel which knows how to manage it if a command is a native command of Windows. If it is a command of Linux, the translation service would be called and through that point, the request would be forwarded to the freshly instantiated process in which the Linux instance has been hosted (i.e., Pico process). When the command is run, the outcome is again translated into an appropriate command that the NT kernel could understand.

WSL is a Windows feature that permits developers to execute the Linux environment without the requirement for an isolated dual booting or virtual machine. Two WSL versions are available, called WSL 1 and WSL 2. First, WSL 1 acts as a compatibility layer to run Linux binary executables (ELF format). It is available on Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows 11, Windows 10 LTSB/LTSC, and Windows 10.

WSL 2 was disclosed, in May 2019, introducing important modifications like an original Linux kernel from a Hyper-V feature subset. WSL 2 is different from WSL 1 as WSL 2 executes in an organized virtual machine that operates the complete Linux kernel. WSL 2 is suitable for more Linux binaries as compared to WSL 1 because not every syscall was operated in WSL 1.

WSL 2 has been available for customers of Windows 10 from a Windows Insider program, such as the Home edition, since June 2019. WSL isn't available to every user of Windows 10 by default. However, it can be installed manually or by adding the Windows Insider program. As of 2022, WSL 2 contains Linux kernel 5.15.74.2.

History of WSL

The first foray of Microsoft into getting Unix-like compatibility over Windows started using the Microsoft POSIX Subsystem, overruled by Windows Services for UNIX by Interix/MKS which was ultimately detracted with the Windows 8.1 release. The technology behind the WSL originated within the unreleased Project Astoria that enabled a few Android applications to execute on Windows 10 Mobile editions. It was initially made present in Windows 10 Insider Preview build 14316.

On the other hand, the previous projects of Microsoft and the third-party Cygwin had concentrated on making their specific Unix-like environments that are based on the standard of POSIX. WSL focuses on the native compatibility of Linux. Rather than covering non-native functionality into the Win32 system calls as Cygwin did.

The initial design of WSL leveraged the NT kernel executive for serving Linux programs as the isolated and special minimal processes (called pico processes) connected to pico providers kernel mode as dedicated system call and many exception handlers different from a vanilla NT process, deciding for reutilizing previous implementations of NT wherever possible.

  • The beta version of WSL was released in the 10 version of Windows 1607 (Anniversary Update) on 2 August 2016.
  • Only Ubuntu was supported. Also, the WSL beta was known as "Bash on Windows" or "Bash on Ubuntu on Windows".
  • WSL was no longer a beta version in the 10 version of Windows 1709 (Fall Creators Update) published on 17 October 2017.
  • Multiple distributions of Linux can be installed and were present to install within the Windows Store.
    Hence, WSL was much speedy and arguably much more famous as compared to its relative Unix-on-Windows projects by this initial design.
  • The engineers of the Windows kernel detected difficulty in attempting to enhance the syscall compatibility and performance of WSL by attempting for reshaping the old NT kernel to operate and recognize accurately on Linux API.

Microsoft published a test build of Windows 10 that also contains the ability to execute Linux GUI applications using CBL-Mariner and WSL 2 in April 2021. The WSLg (Windows Subsystem for Linux GUI) was officially published at a conference of Microsoft Build 2021. It is contained in the Windows 10 Insider build 21363 or later versions.

Microsoft published the WSL Windows Store version on 11 October 2021 for windows 11.

Features of WSL

WSL is accessible in Windows 10 versions (from the 1607 version) and Windows Server 2019, though just in 64-bit versions.

Microsoft considers WSL as "mainly a tool for developers - specifically web developers and those who work with or on open-source projects. In 2018 September, Microsoft stated that "WSL requires fewer resources (CPU, memory, and storage) than a complete virtual machine" (which before WSL was one of the most direct ways for running Linux software inside a Windows environment), while also permitting users for using Linux tools and Windows applications on a similar set of files.

Ubuntu WSL
  • The initial WSL release gives a Linux-compatible interface of kernel integrated by Microsoft, including no Linux kernel code, which then can execute the user space of the Linux distribution on the head of it like Kali Linux, Debian, SUSE Linux Enterprise Server, OpenSUSE, and Ubuntu.
  • Such a user space may include a command language and GNU Bash shell along with several native tools of GNU command-line (awk, sed, etc.), programming language interpreters (Python, Ruby, etc.), and also graphical applications with an X11 server on the host side.

The WSL architecture was recreated in WSL 2 along with a Linux Kernel executing in a lightweight environment of a virtual machine.

wsl.exe

The command, i.e., wsl.exe is used for managing distributions in WSL within the command line. This command can list all distributions available, uninstall distributions, and set the default distribution. Also, it can be used for running Linux binaries through the Windows PowerShell or Windows Command Prompt. The wsl.exe command substitutes the lxrun.exe command which is detracted as of Windows 10 1803 and other versions.

WSLg

It is an abbreviation for Windows Subsystem for Linux GUI created with the aim of enabling support to run Linux GUI applications (Wayland and X11) on Windows in a completely integrated experience of the desktop. Officially, WSLg was published at the conference of Microsoft Build 2021. It is contained in the Windows 10 Insider build 21364 or later versions.

Although, WSLg is finally ported with a production establishment of Windows bringing support for both audio and graphics in WSL applications with the Windows 11 introduction.

Prerequisites to run WSLg include:

  • A system using virtual GPU activated for WSL is suggested because it will permit us to advantage from OpenGL rendering (hardware accelerated)
  • Windows 11 Insider Preview (21362+ builds) or Windows 11 (22000.* build)

Design of WSL

WSL 1 Design

LXSS Manager Service is a service in interacting charge with the subsystem (from the drivers lxcore.exe and lxss.exe) and the form that Bash.exe (don't be confused with the Shells given by the Linux distributions) releases the Linux processes, managing the Linux binary locks, and system calls at the time of their execution. Every process of Linux invoked by a specific user goes into the "Linux instance" (usually, init is the initial involved process). The instance is also closed once each application is closed.

  • The design of WSL 1 provided no hardware virtualization/emulation (unlike other projects like coLinux) and enables direct use of a host file system (from DrvFS and VolFS) and a few hardware parts like the network which assures interoperability.
  • For example, web servers can be used from similar IP addresses and interfaces configured on a host and distribute similar restrictions on the port uses that need administrative permissions.
  • WSL 1 isn't capable of executing every Linux software like 32-bit binaries or those that need particular services of Linux Kernel not done in WSL.
  • Kernel modules like device drivers can't be run because of the insufficiency of a 'real' Linux kernel in this version.
  • However, WSL 2 makes use of active virtualized instances of the Linux kernel.
  • It is possible to execute a few graphical applications like Mozilla Firefox by installing the X11 server in the Windows environment (like Xming or VcXsrv).
  • Also, support for CUDA and OpenCL is not currently being implemented, although planned for further releases.
  • Microsoft said that WSL was established for the application development and not for production servers or desktop computers, recommending the virtual machine uses (Hyper V), Azure, and Kubernetes for those purposes.

WSL 2 Design

The WSL 2 version defines modifications within the architecture. Microsoft has assigned for visualization from a highly optimized Hyper V feature subset to execute the distributions and the kernel, promising performance similar to WSL 1. Developers do not need to modify anything in their released distributions for backward compatibility. The settings of WSL 2 can be pulled via the WSL Global configuration, included in an INI file called .wslconfig inside the User Profile folder.

The installation of the distribution resides in an ext4-formatted file system within a virtual disk. Transparently, the host file system is accessible from the 9P protocol, the same as the other technologies of a virtual machine such as QEMU. Microsoft guaranteed up to 20 times the write/read WSL 1 performance for the users. An IFS network redirector is given for the guest file excess of Linux with the \\wsl$ UNC path prefix from Windows.


Next TopicUnetbootin Ubuntu





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA