How to deploy Windows Subsytem for Linux 2 with WVD

In a previous blog I showed how you could use Linux in Windows Virtual Desktop when we don't actually support Linux hosts. This is possible by deploying "Nested Virtualisation" which is available on certain Azure Virtual Machines. 

This then allows you to run Hyper-V on your Azure VM. Inside Hyper-V you can then run any other "nested" VM, including a Linux distro. You can also run the Windows Subsystem for Linux. This allows you to interact with the VM through the locally installed Linux distro from within Windows.

With the release of the Windows 2004 release we have also released Windows Subsystem version 2. More information in WSL2 is available in this announcement blog

So how do you enable WSL2 from within Windows Virtual Desktop? - Read on.......

Set up a new Host pool

Windows Subsystem for Linux V2 is only available on Windows 10 2004 release. At the time of writing this release is not yet available as an image in the WVD deployment. Hence you need to create a WVD host pool without a session host(s) and then deploy a Windows 10 Azure Virtual Machine and add it to your new host pool.

To create an "empty" host pool follow this guide. You can also do this very easily in the Azure Portal, just go through the host pool creation process and on the Virtual Machines tab, select No to "Add virtual machines:

Once this Host pool has been created copy the Registration Key. Go to the Host pool and click on Registration Key:


Now go to the Azure portal and create a Windows 2004 release VM, this link takes you to the Multi Session image with M365 apps. You could also deploy the single session OS if you are doing personal desktops.

Once the VM is up and running you need to join it to your Active Directory domain and then register your VM with your new host pool, by installing the Windows Virtual Desktop Agent. This is where you will need to paste in your copied Registration key, as well as the Windows Virtual Desktop Agent Bootloader - Follow this section of the above guide

Make sure to remove any public IP address previously assigned to this VM.

Now connect to this VM through any of the WVD clients to confirm connectivity.

Install WSL2

Follow the following steps to install and configure WSL2 and your Linux Distro

On your Virtual machine open an Administrator PowerShell window and run the following command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart your VM.
Once restarted open your Administrator PowerShell window again and run:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Restart your VM again

Set WSL to default to version 2, by running:

wsl --set-default-version 2


You may receive an error stating that the kernel needs to be updated:


In a browser go the the URL listed and download the wsl_update_x64.msi and install it.




Now WSL is updated you can install your Linux distro. To view the Linux distros together in the Microsoft Store, open this link and select the Linux distro you want:

 

I am installing Ubuntu, click on Get:


Once installed click on Launch:


This will now finish installing which could take a few minutes:


Once completed configure your user account:


Once completed check which version of WSL this distro is using. Back in your Admin PowerShell window enter:

wsl --list --verbose

to show the Version:



If showing Version 1, then to upgrade enter:

wsl --set-version Ubuntu 2 

(replace Ubuntu with your distro name if using another)



Once complete run check the version by running the version command again:

wsl -l -v



Now you should have Ubuntu (or your distro) running inside a WVD session:



Comments

  1. Hi Tom. Should we be doing any XML redirection with this? Seems I get errors no matter the distro because it cannot write or edit /var. I'm an admin on the system on a direct assignment to a personal WVD.

    ReplyDelete

Post a Comment

Popular posts from this blog

Reassign a WVD Personal Session Host

AVD and Azure Active Directory Domain Join public preview

How to deploy a Windows Virtual Desktop host pool using Infrastructure as code from Azure DevOps