Blog Post

ITOps Talk Blog
2 MIN READ

WSL2 now available on Windows Server 2022

Pierre_Roman's avatar
Pierre_Roman
Icon for Microsoft rankMicrosoft
May 31, 2022

Hello folks!

 

If you’re one of those Devs/ITPros using the Windows Subsystem for Linux (WSL) you know how useful and powerful it can be.  We announced during Microsoft Build last week that WSL2 will be broadly available in June.  But I could not wait.  Here’s how I installed it.  It’s pretty simple.

 

Check it out!

 

 

 

Pre-Requisites

 

First, Windows Subsystem for Linux requires Hyper-V and virtualization enabled on your computer.

 

Second, if you wait until June, you will get the update that is required for WSL2 to run properly on a Windows Server 2022, through the regular update process.  If you cannot wait you need to install the May 24, 2022—KB5014021 (OS Build 20348.740) Preview.  In the notes for the update, it does mention that you must install KB5005039, dated August 10, 2021, before installing the latest cumulative update (LCU).

 

In my case, my Windows Server 2022 box was already up-to-date so I was able to install the KB5014021 update by selecting it in the Optional quality update Section of the Windows Update section in Settings.

 

 

Installing WSL2

 

The Windows Server Installation Guide as of the writing of this post has yet to be updated to show the procedure to install WSL2 on a Windows Server 2022.  However, the Install Linux on Windows with WSL documentation works beautifully as long as you’ve enabled the "Windows Subsystem for Linux" optional feature and rebooted first.

 

To do this we use the following command :

 

 

 

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

 

 

 

Now, to install the Windows Linux Subsystem, open PowerShell as Administrator and run this command:

 

 

 

wsl --install

 

 

 

Note: If you want to install additional distributions from inside a Linux/Bash command line (rather than from PowerShell or Command Prompt), you must use .exe in the command: wsl.exe --install -d <Distribution Name> or to list available distributions: wsl.exe -l -o

 

 

And reboot your system.

 

After the reboot the installation will resume automatically.

 

 

Set up your Linux user info

 

Once the Install is complete Ubuntu (the defaults distro, unless you specify one as mentioned in the Note above) will start and ask you to complete the setup by providing a username and a password for the account for your newly installed Linux distribution. See the Best practices for setting up a WSL development environment guide to learn more.

 

That’s it.  It’s ready for you and available in your start menu.

 

 

Cheers!

 

Pierre

Updated Nov 09, 2023
Version 2.0
  • Prince's avatar
    Prince
    Copper Contributor

    I am not able to use Windows Subsystem for Linux after I reinstalled Windows 11 Home version 24H2 after resetting my Dell Inspiron 5410 laptop. The same occurred with my friend on a Windows 11 Pro laptop.
    Before the reset, the Windows Subsystem for Linux was working fine on both of our laptops.

    I tried following these steps to fix the issues. 

    Step 1: I tried "Turn Windows features on or off," in which I enabled Windows Subsystem for Linux, which should make me use Ubuntu on my Windows PC after upgrading to version 2 using a kernel update.
    when I tried to update the WSL kernel 

    By downloading and installing the latest WSL 2 kernel from Microsoft’s WSL Kernel Update.
    https://learn.microsoft.com/en-us/windows/wsl/install-manual 
    Step 4: Download the Linux kernel update package.

    It says, "This update is applicable to machines with the Windows subsystem for Linux."

    and does not install updates


    WSL allows the following features:
    Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL). Develop cross-platform applications, improve your data science or web development workflows, and manage IT infrastructure without leaving Windows.
    Key features:
    - Efficient command line utilities, including bash, ssh, git, apt, npm, pip, and many more
    - Manage Docker containers with improved performance and startup times
    - Leverage GPU acceleration for AI/ML workloads with NVIDIA CUDA
    - A consistent development-to-deployment workflow when using Ubuntu in the cloud

    But "Turn Windows features on or off" did not help.


    Step 2:
     Then, I tried installing WSL manually with the following codes:

    https://learn.microsoft.com/en-us/windows/wsl/install-manual
    Step 1 - Enable the Windows Subsystem for Linux
    Step 3 - Enable Virtual Machine feature



    PS C:\WINDOWS\system32> .exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    >>

    Deployment Image Servicing and Management tool
    Version: 10.0.26100.1150

    Image Version: 10.0.26100.2605

    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.

    PS C:\WINDOWS\system32> .exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    >>

    Deployment Image Servicing and Management tool
    Version: 10.0.26100.1150

    Image Version: 10.0.26100.2605

    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.

    Although it ran, it was not helpful even after 100 percent installation, but it did not help.


    Step 3: I tried following the codes in PowerShell as Administrator:
    wsl.exe --install
    wsl --install
    wsl.exe --update

    PS C:\WINDOWS\system32> wsl.exe --install
    Class not registered
    Error code: Wsl/CallMsi/Install/REGDB_E_CLASSNOTREG

    PS C:\WINDOWS\system32> wsl --install
    Class not registered
    Error code: Wsl/CallMsi/Install/REGDB_E_CLASSNOTREG

    none of these codes helped.



    Step 4. When I tried running the command Bash in PowerShell as Administrator.

    C:\Windows\System32>bash


    Class not registered
    Error code: Bash/CallMsi/Install/REGDB_E_CLASSNOTREG


    It did not run.

    Step 5: I verified virtualization is enabled in BIOS.

    • Restart your computer and access the BIOS/UEFI (usually by pressing F2, Del, or a similar key during boot).
    • Look for settings like Intel Virtualization Technology (VT-x) or AMD-V and ensure they are enabled.
    • Save changes and reboot into Windows.


    Step 6: Another error was given
    Error: 1168

    Error code 1168 usually translates to "Element not found" in Windows. This error indicates that some required files, registry entries, or features are missing or improperly configured. In the context of WSL installation.

    Step 7: I even tried reinstalling Windows, which did not help.

    Step 8: I installed Windows 11 (multi-edition ISO for x64 devices).

    https://www.microsoft.com/en-us/software-download/windows11

    But this also does not fix my issue.

    Step 9: Even the Windows customer support team was not able to help.




    I guess this is the issue with most of the system. Please help me fix it.
    and there may be a bug in Windows 11.

  • Prince's avatar
    Prince
    Copper Contributor

    I am not able to use Windows Subsystem for Linux after I reinstalled Windows 11 Home version 24H2 after resetting my Dell Inspiron 5410 laptop. The same occurred with my friend on a Windows 11 Pro laptop.
    Before the reset, the Windows Subsystem for Linux was working fine on both of our laptops.

    I tried following these steps to fix the issues. 

    Step 1: I tried "Turn Windows features on or off," in which I enabled Windows Subsystem for Linux, which should make me use Ubuntu on my Windows PC after upgrading to version 2 using a kernel update.
    when I tried to update the WSL kernel 

    By downloading and installing the latest WSL 2 kernel from Microsoft’s WSL Kernel Update.
    https://learn.microsoft.com/en-us/windows/wsl/install-manual 
    Step 4: Download the Linux kernel update package.

    It says, "This update is applicable to machines with the Windows subsystem for Linux."

    and does not install updates


    WSL allows the following features:
    Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL). Develop cross-platform applications, improve your data science or web development workflows, and manage IT infrastructure without leaving Windows.
    Key features:
    - Efficient command line utilities, including bash, ssh, git, apt, npm, pip, and many more
    - Manage Docker containers with improved performance and startup times
    - Leverage GPU acceleration for AI/ML workloads with NVIDIA CUDA
    - A consistent development-to-deployment workflow when using Ubuntu in the cloud

    But "Turn Windows features on or off" did not help.


    Step 2:
     Then, I tried installing WSL manually with the following codes:

    https://learn.microsoft.com/en-us/windows/wsl/install-manual
    Step 1 - Enable the Windows Subsystem for Linux
    Step 3 - Enable Virtual Machine feature



    PS C:\WINDOWS\system32> .exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    >>

    Deployment Image Servicing and Management tool
    Version: 10.0.26100.1150

    Image Version: 10.0.26100.2605

    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.

    PS C:\WINDOWS\system32> .exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    >>

    Deployment Image Servicing and Management tool
    Version: 10.0.26100.1150

    Image Version: 10.0.26100.2605

    Enabling feature(s)
    [==========================100.0%==========================]
    The operation completed successfully.

    Although it ran, it was not helpful even after 100 percent installation, but it did not help.


    Step 3: I tried following the codes in PowerShell as Administrator:
    wsl.exe --install
    wsl --install
    wsl.exe --update

    PS C:\WINDOWS\system32> wsl.exe --install
    Class not registered
    Error code: Wsl/CallMsi/Install/REGDB_E_CLASSNOTREG

    PS C:\WINDOWS\system32> wsl --install
    Class not registered
    Error code: Wsl/CallMsi/Install/REGDB_E_CLASSNOTREG

    none of these codes helped.



    Step 4. When I tried running the command Bash in PowerShell as Administrator.

    C:\Windows\System32>bash


    Class not registered
    Error code: Bash/CallMsi/Install/REGDB_E_CLASSNOTREG


    It did not run.

    Step 5: I verified virtualization is enabled in BIOS.

    • Restart your computer and access the BIOS/UEFI (usually by pressing F2, Del, or a similar key during boot).
    • Look for settings like Intel Virtualization Technology (VT-x) or AMD-V and ensure they are enabled.
    • Save changes and reboot into Windows.


    Step 6: Another error was given
    Error: 1168

    Error code 1168 usually translates to "Element not found" in Windows. This error indicates that some required files, registry entries, or features are missing or improperly configured. In the context of WSL installation.

    Step 7: I even tried reinstalling Windows, which did not help.

    Step 8: I installed Windows 11 (multi-edition ISO for x64 devices).

    https://www.microsoft.com/en-us/software-download/windows11

    But this also does not fix my issue.

    Step 9: Even the Windows customer support team was not able to help.




    I guess this is the issue with most of the system. Please help me fix it.
    and there may be a bug in Windows 11.

     

  • Krishnam2345's avatar
    Krishnam2345
    Copper Contributor

    Hello,

    Thank you for sharing this information.

     

    could you please please advise if there is a way to install  Linux distribution offline: Install Linux Subsystem on Windows Server | Microsoft Learn

     

    I have gone through above link but unfortunately installation of distribution fails with WSL --install on Win 2022, as the server is on corporate network.

     

    I tried to download the following packages and those to windows app via Add-AppxPackage

    1) Microsoft.VCLibs.x64.14.00.Desktop.appx

    2) Ubuntu2204-221101.AppxBundle

     

    I see the app is installed but encountering following issue:

     
     

    28141501-0d2df010-671a-11e7-8690-3962d5c1c9a1.png (1111×266) (user-images.githubusercontent.com)

     

    could you please advise on this matter, Thank you!!

     

     

  • CarlesCarles's avatar
    CarlesCarles
    Copper Contributor

    Thanks for writing this up!

    Could you confirm (because I'm having some problems) that graphical applications such as "gedit" work on the WSL2 on Windows 2022?

    Just doing:

    apt install gedit
    gedit

    There should be either an error message (that I get) or the application running.

    I'd be happy to know if I'm trying the impossible or it's supposed to work 🙂

    Thank you!

     

  • Thanks for sharing, this is positively AMAZING 🙂

     

    Happy Azure Stacking!!!