Interoperation between Linux and Windows has been a challenge for system operators for a very long time. Over the past 20 years, systems administrators have used emulators, virtual machines, and even recompiled UNIX binaries to run on Windows in order to access the tools they need to manage applications and services running on operating systems different from their workstation. Sysadmins and security engineers working in enterprises that run Windows as their standardized desktop operating system must find creative ways to manage their Linux systems beyond the tried and true Secure Shell (SSH) connection to a remote host running Linux. Over the last few years, Microsoft made a turn to more explicitly support Linux (and open-source tools in general). It incorporated SSH directly into Windows, allowing sysadmins to remotely connect to other Linux systems without needing third-party tools. In April 2020, Microsoft announced the release of Windows Subsystem for Linux 2.0 (WSL 2), the latest iteration of its direct support for Linux directly from a Windows workstation.
Microsoft has supported *NIX operating systems for over 20 years. In 1999, Microsoft released Services for UNIX (SFU), which included a POSIX compatible emulator capable of running a subset of UNIX software compiled specifically for it. In 2016, Microsoft released the Windows Subsystem for Linux 1.0 (WSL 1), which provided a Linux “compatible” kernel interface. Using WSL 1, you could install popular Linux distributions alongside your Windows installation. The experience was good, although performance at times was slower than a virtual machine (VM) running Linux and not all hardware features and system calls were enabled. But WSL 1 became a solid choice for users requiring a Linux environment broadly locally accessible on their Windows workstation.
Microsoft updated the WSL 2 architecture with two stated primary goals: increase file system performance and add full Linux system-call compatibility. Unlike WSL 1, which relied on a translation layer between the Linux environment and the Windows host, WSL 2, will use an actual Linux kernel that Microsoft tuned to run specifically with its implementation architecture. The WSL 2 kernel will be in a virtual machine atop the Windows hypervisor in parallel to the Windows OS itself. WSL 2 operates with more virtualization technology than WSL 1, but its architecture differs quite a bit from simply running a Linux distribution on Hyper-V as a VM.
Like WSL 1, WSL 2 will support multiple distributions that you can install and run in parallel. However, each distribution will run in a common virtual machine to keep the VM as lightweight and host system as performant as possible. When you kill the Linux applications, the VM stops as well. WSL manages communications between the VM running the Linux Kernel and the Windows user interface. For example, WSL redirects the standard input-output from the VM to the host system. (This means that when you run the Bash shell from within WSL 2, you will see the output in a new window on your Windows workstation.)
Moving WSL to a VM architecture required Microsoft to change how files are accessed between the Windows and Linux environments. In WSL 1, the Windows and Linux environments shared the same operating system and accessing files between the two environments was direct, because the Linux environment had access to the Windows New Technology File System (NTFS). However, because WSL 2 operates as a virtual machine, Microsoft needed a different approach to make the file systems visible to each environment. Microsoft leveraged file-server technology (the preview uses the Plan 9/9P protocol) to serve files between both Windows and Linux environments. Depending on which environment is making the request, either Windows or Linux environments can act as the file server or client. For example, if you want to access a file stored on Windows from Linux, the Linux client connects to a 9P-hosted file server on the Windows server and mounts a share the Linux OS can access.
Despite this new architecture, Microsoft emphasized making sure the WSL 2 user experience remained as seamless as possible. For example, by redirecting the standard input and output between the environments and using file server technologies, you can launch a Windows editor to make a change to a Linux file. Similarly, in the Linux environment you can launch cmd.exe or PowerShell from Bash to operate on the Linux files, although the binary runs from the Windows environment.
To install WSL 2, subscribe to the Windows Insider preview program and upgrade your test Windows 10 workstation to at least version 18917 or higher.
From an elevated PowerShell prompt, run the commands:
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
And reboot your workstation.
Set the default version of WSL to version 2.0:
wsl --set-default-version 2
Visit the Microsoft store and download and install your desired distribution per the instructions. The store includes many popular distributions, including Ubuntu, openSUSE, Debian and even the security distribution Kali.
After you have installed kali, open an admin PowerShell terminal and make sure Kali is running using WSL 2 by running the command:
wsl -l -v
To start the newly installed Kali distribution, run the command:
Kali will start and from here you can operate much like a typical Linux console but now can use some of the tools not available in WSL 1. For example, after you have updated and upgraded your distribution,
sudo apt update
sudo apt upgrade
From here, you can download and install the programs you need and might be pleasantly surprised at the broader compatibility provided by WSL 2.0. While an official release date has not been announced, WSL 2 is included in the Windows preview program. Click here for additional information and detail about WSL and whether it might be a nice addition to your own workstation.
Accessing all the tools you need from your primary workstation might save you time and effort, and Microsoft’s WSL2 makes it easier for Linux admins to access their Linux tools from their Windows workstation. Microsoft continues to advance WSL providing enhanced performance and broader support for more system calls, which means greater compatibility with the tools sysadmins use every day. WSL2 makes it even easier to find and edit files across Windows and Linux environments with favored tools from either environment.
Jeff Fellinge has over 25 years’ experience in a variety of disciplines ranging from Mechanical Engineering to Information Security. Jeff led information security programs for a large cloud provider to reduce risk and improve security control effectiveness at some of the world’s largest datacenters. He enjoys researching and evaluating technologies that improve business and infrastructure security and also owns and operates a small metal fabrication workshop.
Privacy Center |
Terms and Conditions
Copyright ©2021 Mouser Electronics, Inc.
Mouser® and Mouser Electronics® are trademarks of Mouser Electronics, Inc.
All other trademarks are the property of their respective owners.
Corporate headquarters and logistics center in Mansfield, Texas USA.