Photo by Jack Hunter on Unsplash

Photo by Jack Hunter on Unsplash

Windows Subsystem for Linux and Android in Windows 11

Good Host

Article from ADMIN 72/2022
By
The Windows subsystem for Linux runs graphical applications on Windows 11 out of the box, and Windows Subsystem for Android, out in preview at press time, shows that Windows can be a platform for Android apps. We look at the state of the art and help you get started.

High-ranking Microsoft employees publicly making disparaging remarks about Linux is ancient history. Redmond has changed its course 180 degrees and impressively demonstrated that its commitment to the development of open source software is not mere lip service. For example, GitHub, the platform for collaborative version management for countless free projects, was acquired by Microsoft in 2018. However, Microsoft does not just operate the platform, it also actively contributes to many projects as one of the world's largest open source providers.

Additionally, Microsoft has developed its own Linux distribution named CBL-Mariner – where CBL stands for Common Base Linux – which you will find on GitHub, of course [1]. However, CBL-Mariner is by no means designed to compete with established Linux distributions for general-purpose use. Microsoft mainly uses its in-house distribution itself, following an approach that is most comparable to Fedora CoreOS. CBL-Mariner, as a minimalist distribution, is primarily geared toward running containers. It forms the basis for the Azure Kubernetes Services and other services in the Azure cloud. However, CBL-Mariner is not only relevant for Microsoft's cloud activities, it now also handles tasks under the hood of the Windows Subsystem for Linux (WSL).

Graphical Linux Apps

The second version of WSL sees Microsoft place the subsystem on completely new underpinnings. The basis is the Windows Virtual Computer Platform feature, which also provides the foundation for Hyper-V. Unlike Hyper-V, however, WSL does not rely on full virtualization, but on containers. In concrete terms, this means that not every Linux distribution installed in WSL will run on a fully virtualized machine, but all distributions share a common kernel. The advantage is that WSL gets by with significantly fewer resources than Hyper-V.

That said, during my last visit to the site, some add-ons were still missing, and I had to resort to an X server on Windows to run graphical Linux applications [2]. Native support for X11 and Wayland apps was initially only found as a preview in the Windows Insider program. After the introduction of Windows 11, Microsoft has finalized the Windows Subsystem for Linux GUI (WSLg) [3]. The basis for this is the WSLg system distribution based on CBL-Mariner (Figure 1), which runs Weston, the reference implementation of the server for the Wayland remote display protocol that Microsoft has adapted for use with WSL and optimized for displaying individual applications instead of entire desktop environments over the Remote Desktop Protocol (RDP). Besides Wayland applications, WSLg can also handle classic X11 applications. The additional Pulse Audio Server takes care of the bidirectional transmission of audio signals.

Figure 1: The CBL-Mariner system distribution converts the Wayland and X11 display protocols to RDP.

When you work with WSL, you will not see any of this architecture, which seems complex at first glance but offers several advantages. The applications within your user distributions, of which you can install and run several in parallel, use their familiar Linux interfaces without customization. Windows, on the other hand, accesses them by RDP without having to worry about implementing X11 or Wayland. In this way, Linux applications can also use the host's physical GPUs, if available. This setup not only benefits graphically intensive applications, but also those that require GPUs for machine learning (ML) or artificial intelligence (AI) use cases. Microsoft has ported the DirectX 12 interface to Linux for this purpose with its own kernel driver [4].

Upgrade from Windows 10 to 11

Microsoft has reserved WSLg exclusively for Windows 11 and has not backported it to Windows 10. The good news is that if you own a Windows 11-capable device, you can safely update. In the lab, existing Linux instances survived an upgrade installation from Windows 10 to 11 without any complications.

After an upgrade, just make sure that WSL is up to date and that your Linux instances are all using version 2 of the subsystem. You can do this at the command line with admin privileges and list all existing Linux distributions by typing:

wsl --update
wsl --list -v

If you find a distribution that has not yet moved to version 2, you can change that with

wsl --set-version <name of distribution> 2
wsl --shutdown

and restart the subsystem.

Two Approaches to a Fresh Install

If you start with a fresh installation of Windows 11, on which WSL has not run so far, two approaches can give you the desired state. Before you start, make sure that hardware virtualization is active in your system's BIOS. The WSL setup does not check this state and responds with some less than meaningful hex code as an error message if you try to launch a Linux distribution. The hardware virtualization is called Intel VT-d/VT-x or AMD IOMMU , depending on the processor manufacturer, but it can also be hidden under other terms or in a submenu in the BIOS depending on the brand of your computer. If in doubt, consult the manufacturer's documentation.

If hardware virtualization is active, you can pop up an admin command line and install WSL with just one command that will do all the work for you:

wsl --install

The command starts by installing the required Windows features, the Virtual Computer Platform, and the Windows Subsystem for Linux if they are not already in place. You can also see this for yourself on Windows 11 in the legacy Control Panel in Programs and Features | Turn Windows features on or off . The setup routine then loads the current long-term support (LTS) version of Ubuntu from the Microsoft Store as the default distribution. If you prefer some other distribution, such as Kali Linux, which is popular among forensic experts, try:

wsl --install --distribution kali

Although the advantage is that this command handles all the required steps in one fell swoop, this approach has a drawback.

When installing with wsl.exe, the subsystem itself and the Linux kernel use the Windows Update service to retrieve updates and the operating system; however, this approach is no longer preferred by Microsoft. Instead, Microsoft wants to decouple the updates for WSL from the operating system and deliver them from the Microsoft Store [5]. You can find WSL in the Microsoft Store as Windows Subsystem for Linux Preview, but don't worry that Microsoft currently still rates the app as a preview. It gives you the identical feature set – just not as a Windows feature, but as a state-of-the-art Store app.

Unlike the wsl command, however, the Store app unfortunately does not take care of dependencies. Without the virtual machine platform, attempting to run a Linux distribution ends up with a hex code error and a note to the effect that a required feature is not installed. You need to add this feature to Windows first from the control panel or with

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all

on a command line with admin privileges.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=