, , ,

How to Install WSL 2 on Windows Server

1–2 minutes
17 comments on How to Install WSL 2 on Windows Server
Windows Subsystem for Linux 2 on Windows Server 2022

With the latest Windows Server 2022 cumulative update (June 2022), you are also able to run WSL 2 on Windows Server. In this blog post, I am going to show you how you can install the Windows Subsystem for Linux 2 (WSL 2) on Windows Server. The Windows Subsystem for Linux was already available in earlier versions of Windows Server; however, WSL 2 brings a lot of new advantages. WSL 2 will be available on Windows Server 2022 broadly with the June cumulative update and if you want to run it today, you can install the 5C update here.

WSL 2 on Windows Server
WSL 2 on Windows Server

The Windows Subsystem for Linux was in Windows 10 and Windows 11 for a while now and allowed you to use different versions of Linux on your Windows client machine. With WSL 2, the architecture will change drastically and will bring increased file system performance and full system call compatibility. WSL 2 is now using virtualization technology (based on Hyper-V) and uses a lightweight utility VM on a real Linux kernel. You can find out more about WSL 2 in the release blog or on the Microsoft Docs Page for WSL 2.

Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server

Here is how you can install WSL 2 on Windows Server.

Prerequisites:

KB5014021 for WSL 2 on Windows Server
KB5014021 for WSL 2 on Windows Server

After you have installed Windows Server 2022 with the latest update, you will need to add the following features:

  • Microsoft-Windows-Subsystem-Linux
  • VirtualMachinePlatform

To enable these features, run the following command:

wsl --install

This command will need a restart to complete.

Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server 2022
Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server 2022

This will also download Ubuntu as for your WSL 2 Linux distro.

Windows Subsystem for Linux 2 on Windows Server 2022
Windows Subsystem for Linux 2 on Windows Server 2022

I hope this gives you a step-by-step guide on how you can install WSL 2 on Windows Server. If you want to install the Windows Subsystem for Linux (1( on Windows Server 2019, check out this blog post: Install Windows Subsystem for Linux on Windows Server.

17 responses

  1. Tim Avatar

    Ignore my previous comment. Figured it out.

    PS C:\Windows\system32> wsl –set-version Ubuntu-18.04 2
    Conversion in progress, this may take a few minutes…
    For information on key differences with WSL 2 please visit https://aka.ms/wsl2
    Conversion complete.
    PS C:\Windows\system32> wsl -l -v
    NAME STATE VERSION
    * Ubuntu-18.04 Stopped 2

    1. Thomas Maurer Avatar

      Great that it worked! :)

  2. Graham Avatar

    Very cool information and simple walkthrough. FYI, 2 small typos in your shell scripts above referencing Ubuntu1894 instead of Ubuntu1804.

    1. Thomas Maurer Avatar

      Thanks :) and thanks for letting me know about the typos. They should be fixed now :)

  3. Marcelo Costa Avatar
    Marcelo Costa

    I cannot set wsl to version 2. Seems several options are not available. My wsl output is:
    PS C:\Users\Administrator> wsl –set-version Ubuntu-20.04 2
    Invalid command line option: –set-version
    Usage: wsl.exe [option] …
    Options:
    -d, –distribution
    Launch the specified distribition.

    -e, –exec
    Execute the specified Linux command. The remainder of the arguments are
    used as the command line to execute.

    -u, –user
    Run as the specified user.

    –help
    Display this usage information.

    —
    Stop parsing arguments and pass the remainder to the Linux process.

    OR

    PS C:\Users\Administrator> wsl –set-default-version
    Invalid command line option: –set-default-version
    Usage: wsl.exe [option] …
    Options:
    -d, –distribution
    Launch the specified distribition.

    -e, –exec
    Execute the specified Linux command. The remainder of the arguments are
    used as the command line to execute.

    -u, –user
    Run as the specified user.

    –help
    Display this usage information.

    —
    Stop parsing arguments and pass the remainder to the Linux process.

    1. Thomas Maurer Avatar

      Hi Marcelo

      Which version of Windows 10 are you running?

  4. Bose Avatar

    hi, Thomas,

    how can I install WSL2 on my Windows Server 2019?

    Thanks.

    Bose

  5. Janjaap Avatar

    Hi Thomas,

    Thanks for the great blog! I was wondering if it would be possible to enable Docker to run Linux containers on Server insider (20215) with WSL2? I have been searching everywhere, but all tutorials are outdated on this.

    Thanks,

    Janjaap

  6. Anthony Avatar

    Hi, might want to correct this article for those who are misled by it’s title. This is NOT for running WSL 2 on Windows Server, this is currently not possible. It’s for running WSL 2 on Windows 10.

    1. Thomas Maurer Avatar

      You are wrong :) It is for running it on Windows Server. There is another post (see the link) for Windows 10.

  7. Brian Lakstins Avatar
    Brian Lakstins

    I get the same response to wsl.exe commands not supporting the arguments in these instructions.

    Running Windows Server 2019 Datacenter version 1809 build 17763.1637.

    It’s running as a E Series V3 system on Azure.

  8. ddeck Avatar

    I could not get this to run on any build of Windows Server 2019 following your directions – any thoughts? Similar to others I just get the WSL output of the various WSL options.

    1. Thomas Maurer Avatar

      It doesn’t work with Windows Server 2019. You need “Windows Server Insider Preview build 18945 or higher”

  9. LubomirH Avatar
    LubomirH

    Just a note for those who are trying now on Windows Server Preview (actual build 20287).
    The WSL2 bits are broken from build 20251 onward.
    Look here to download the last build where WSL2 works and don’t do an in-place upgrade.
    https://techcommunity.microsoft.com/t5/windows-server-insiders/wsl-2-not-working-after-installing-20262/m-p/2109063/highlight/true?WT.mc_id=modinfra-0000-thmaure#M1601

  10. Lukas Van Oudenhove Avatar
    Lukas Van Oudenhove

    Any news on this Thomas? What about Windows Server 2022?

  11. Knut Avatar

    Hi Thomas,
    it would be a nice utopie – but in the actual WindowsServer2022 (v21H2, build 20348.202) – WSL2 seems not supported anymore. The so far well known ‘wsl –set-default-version 2’ run without any error nor effect – it sticks at WSL1. See that comment here: https://github.com/microsoft/WSL/issues/6301#issuecomment-858816891
    That is a real pity, not only for your well explaining blog post. Can you confirm this?

  12. Ilkin Avatar

    Not working on Azure Windows server 2022

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.