Microsoft’s WSL 2 has graphics support. Here’s how to prepare for it.
Change is coming for WSL.
Image: Getty Images / iStockphoto
Windows Subsystem for Linux (WSL) is an important part of Windows 10. Using a version of Microsoft’s Hyper-V virtualization technology, it allows you to run Linux as if it were part of Windows, by sharing resources and files. It was originally designed for developers who build web and cloud applications, but it has evolved into something much more powerful that brings together two very different operating systems.
SEE: Kubernetes Security Guide (Free PDF) (TechRepublic)
Microsoft originally designed WSL for use with the bash command line, but it has evolved into something much closer to a traditional Linux distribution. Instead of using Microsoft’s original set of shims and translations to convert Linux system calls to Windows calls, it now uses a Linux kernel compiled and supported by Microsoft, initially using kernel version 4.19, but deploying now a more updated version 5.4. This change improved support for Linux applications, most of which run without any modifications. There are a few issues: Because it is a subsystem, it does not start at startup, so there is no support for timed tasks or for services using systemd.
Beyond the command line
The command line is great for much of what Microsoft has planned to use Linux on Windows – testing code and using local copies of Linux-based cloud native application stacks – using the redesigned Windows Terminal. and much improved. But developers and users wanted more, finding ways to integrate familiar Linux desktops into Windows, using Windows versions of X servers that add graphics support to most Linux distributions.
With WSL 1, setting up a GUI was a complex process. Changes in WSL 2 to the way it handles networking made this even more difficult, as the Linux VM no longer shared an IP address with the host Windows operating system. Instead, it is a virtual machine with shared resources, using a virtual switch to share the host’s network adapter. This requires scripts to find the current IP address each time you launch WSL and a change to the security template for any Windows X server.

Image: Microsoft
WSL 2 and the GPU
Microsoft’s promise of a new GUI model for WSL 2 by the 2020 holiday season has been pushed back, possibly due to a delay in the development of the WSL 2 Mesa 3D OpenGL / DirectX bridge that appears to be the key to Linux graphics support without the need for new drivers for all graphics cards supported by Windows. If Microsoft and its partners can provide a way to map Linux OpenGL calls to Windows graphics APIs, that should mean that support for WSL 2 graphics will work, without requiring modifications to Linux distributions hosted on WSL 2 or Windows.
With Mesa 3D offering OpenGL APIs to Windows and Linux from a single set of drivers, it should be possible for Microsoft to provide a Windows-optimized Wayland server that can be installed from any Linux distribution repository. All you need to do is download the server and a Linux desktop environment. The last part of the equation would be a version of a tool like xrdp to deliver a full desktop or set of selected Windows applications to a remote desktop client running Windows.
By the way, it’s worth noting that Microsoft’s partner in its DirectX / Mesa 3D bridge work, Collabora, recently featured a Wayland composer running on WINE. Work like this could easily be used to add Wayland support in Windows Remote Desktop Tools alongside Microsoft’s own RDP protocol.
Using RDP with WSL 2
You can get an idea of how this would work using the new Ubuntu Community Preview version of the Ubuntu WSL environment, if you are using a Dev Channel version of Windows 10. The Ubuntu Community Preview is only not available from Windows Store search: you need to follow a link in Ubuntu WSL 2 blogs to a hidden page to download it. It’s not hidden for some nefarious reason – it’s currently a version of 20.10 intended for beta testers and updated regularly (the next release will likely be a preview of version 21.04). Because each update will require you to reset the distribution’s WSL 2 environment, it is not recommended for daily use.
One of the first tools Ubuntu Community Preview tested is a new out-of-the-box experience and a set of associated configuration tools. These include the ability to prepare Ubuntu for use with WSL 2 networking for GUIs, setting up a script that automatically sets the appropriate DISPLAY environment variables. You can enable it when setting up Ubuntu for the first time or from the built-in configuration tool.
A quick way to add GUI support is to use xrdp, which is quite easy to configure. First use the Ubuntu Package Manager to install a desktop environment. I chose Kubuntu, but there are many other popular options. This adds a lot of GUI-based applications to WSL, as well as a clean and modern desktop environment using Kubuntu’s plasma design language.
SEE: Microsoft 365: A Cheat Sheet (Free PDF) (TechRepublic)
Kubuntu installation can take some time, even on a fast PC, as it has to configure various databases and configuration files as part of an installation. Once installed, all you need to do is make a few small changes to the xrdp configuration files, change the RDP port to 3389, and add better support for PC screens (by increasing the color depth for a better picture) and launching both the dbus message system and xrdp, before using the Windows Remote Desktop Connection tool to open a display from WSL 2.
With RDP and Remote Desktop Connection, you can share your Windows clipboard with WSL 2, cutting and pasting them on terminals running on the Kubuntu desktop. It’s a smooth integration, as WSL 2 on current versions of Insider Dev also exposes its ext4 file system to Windows File Explorer. While you should have a full desktop, and you can’t just bring app windows to the Windows desktop, having a full Linux environment like Kubuntu makes it possible to start thinking about cross-platform workflows and how. you can bring the two environments together.
The future of WSL?
Microsoft’s promised WSL GUI based on Wayland will take a more application-oriented approach to Linux, with preliminary demos showing Linux applications accessible from the Windows desktop and running in their own Windows. If you are using Azure-based Windows Virtual Desktop, you should be familiar with this approach, bringing hosted applications to your desktop while they are running in Azure. You can think of it as a similar approach to tools like Parallels macOS support for Windows, with Windows apps in the macOS Dock.
WSL 2 is an important component of Windows 10, helping Microsoft bring developers back to Windows PCs. The integration of Linux GUI applications with the Windows desktop should make it even more attractive, especially if it can be delivered seamlessly, without requiring additional hardware-specific drivers. The easier it is, the better. With a target audience that only wants to write code, seamlessly breaking down the barriers between Windows and Linux is essential for their future.