Microsoft WSL2 with VMware Horizon

Windows Subsystem for Linux (WSL/WSL2) is a great way to quickly access a Linux environment directly from a Windows OS, without a dual-boot or dedicated virtual machine. It’s fairly simple to set up on Windows 10 and 11. If you want to learn more about it you can start here.

With the growth of WSL, the question came about running it within a VMware Horizon virtual desktop. VMware does have a KB that mentions support for it, but no additional details. Below are the steps to get it working in a VMware Horizon Windows 10 virtual machine.

*I’m not an expert on Microsoft WSL so there may be a way around one challenge I see when using it in a Horizon environment. WSL distros and configuration appear to be user account specific so in a non-persistent environment, such as Instance Clone pools, it won’t function properly. The Linux distro doesn’t appear to be available and would need to be installed for each user. The use case I’m addressing here is a persistent desktop pool where the WSL feature is installed in the base image and it’s left up to each user of a cloned image to install the distro(s) they require. It may be possible to augment a non-persistent pool with writable volumes, but I haven’t had a chance to try that. Please leave a comment if you’ve found a way to make this function for a non-persistent pool.

Windows 10 virtual machine prep

To get started we need to make one change to the virtual machine’s hardware settings. The WSL2 services require full CPU virtualization to be available to the guest OS. We need to expose the CPU fully to the virtual machine to do this. Additional details can be found in the official documentation.

With the virtual machine powered off right-click on the virtual machine and select Edit Settings.

From the Virtual Hardware tab expand CPU. In the Hardware virtualization section select Expose hardware assisted virtualization to the guest OS. Click OK to save the change.

Next, power the VM on.

Install WSL2 on a Windows 10 virtual machine

With the VM powered on log in as an administrator. Then open an administrative command prompt. If you’re unsure how to do that simply type in the Windows Search bar cmd and click the Run as administrator option.

Next, to install WSL2 type the following into the command prompt: wsl.exe –install

Hit Enter and the installation should start, as well as the installation of an Ubuntu distro.

After a minute or two you should see that the operation was successful. Now just reboot the virtual machine to complete the installation.

After the machine reboots log back in and you should see the Ubuntu install completing on its own. Depending on your system this can take several minutes to complete.

When it’s done it will ask for you to set a username and password for the Ubuntu system.

At this point the installation is complete and you can start using WSL2.

Optionally it may be helpful to install the Windows Terminal from the Microsoft Store. This can make interacting with the Ubuntu system a little easier.

After you install the Windows Terminal and Launch it you can access your various distros from the dropdown menu. Select Ubuntu to connect to the default distro.

Now you can interact with your Ubuntu system.

Consideration for WSL2 in a VMware Horizon Environment

One important thing to be aware of is that WSL2 distros are user account specific. There may be a Microsoft configuration to allow them to be shared across user accounts, but I haven’t come across how to do that just yet. Please let me know if there is a way.

Considering that you can follow all the above steps for a Horizon desktop base image. When you clone it to an instant clone desktop pool WSL2 will be installed for all the desktop VMs. The only downside is that the Ubuntu distro will not be available for new users. It will only be available for the account that performed the initial installation.

If you’re building a persistent desktop pool then simply cloning the base image with the WSL2 installation will work fine. The services will be preconfigured in the clones. When the users log in to their assigned virtual machines they will need to go to the Microsoft store and download the Linux distro they want. This does allow for flexibility of what distro they get and being persistent it will stick around for them.

The steps each user would need to follow are outlined below.

Launch the Microsoft Store. Search for Ubuntu or another distro they would like. Below I selected the Ubuntu 22.04.2 LTS version.

Click Get to start the download.

It may take a few minutes depending on your environment. After it completes either click Launch or download the Windows Terminal from the Microsoft Store and connect to the Linux distro as I demonstrated earlier.

At this point, everything should be good to go.

Hopefully, there is a simpler way to make this work in a non-persistent desktop pool because WSL can open up some great tools without additional overhead or management of a dedicated Linux virtual machine.

I hope this was helpful and thank you for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *