Recently had a question related to WSL2. Somehow stumbled on WSL2 installation Windows Server and got shocked. There were no clear directions, even on the Microsoft page, the installation guide was quite confusing. So, here is the simplest possible way to install WSL2 on Windows Server 2019.
Table of Contents
If you are applying the method then you will need to have Windows Server 2019 version 1709 or later.
NOTE: if you don’t know your Windows Server version then you will go to Start > Settings > System > About. There you will find Device specifications > System type and under Windows specifications, you will find all the info needed.
Related Topic: How to install WSL2 on Windows 10?
1: Install WSL1 on Windows Server
The first step will be to install or enable WSL1. Since the WSL1 is present as default then you will need to just enable it. For enabling it, you will run CMD or PowerShell as administer. Then you will use the command below to enable it.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
For installing additional components, you will use this command.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Installing the components are totally optional. Once the installation got completed then you will reboot your system. since after the installation there won’t be major changes to notice, so you can use the command below to check for the installation of WSL on Windows Server.
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
2: Download Linux Distribution
The best way of downloading any Linux distribution is to use Microsoft Store. We have also used Microsoft Store for installing WSL2 on Windows 10 too. Since most of the Windows Servers use Long-Term Servicing (LTSC) desktop OS SKU and have no support for Microsoft Store or can’t access the Store due to Corporate network or admin permit they can use any of the other methods.
Manual
There is a manual option to download the Linux distro which is to use the direct links below. Click on any of the direct links and start downloading the Linux distro.
- Ubuntu 20.04
- Ubuntu 20.04 ARM
- Ubuntu 18.04
- Ubuntu 18.04 ARM
- Ubuntu 16.04
- Debian GNU/Linux
- Kali Linux
- SUSE Linux Enterprise Server 12
- SUSE Linux Enterprise Server 15 SP2
- openSUSE Leap 15.2
- Fedora Remix for WSL
Download with CDM
If don’t like downloading them from the direct links then you can use CMD or PowerShell for the purpose too. You can either use this command:
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx –UseBasicParsing
Or this one.
curl.exe -L -o ubuntu-2004.appx https://aka.ms/wsl-ubuntu-2004
Both commands work fine and the files are totally the same. As both of them uses the exact same server.
Related Topic: How to Download Linux Subsystem for Windows
3: Extraction of the Linux Distros
If you have used the second command for downloading the setup file, then you will probably have a “.exe” file that requires no extraction. You will create a directory by this command:
Md c:\Linux\Ubuntu
If you got zip file format, then you will extract it with the command below after creating the directory by the command above.
Expand-Archive c:\users\administrator\Ubuntu2004.zip C:\Linux\UbuntuExpand-Archive .\Ubuntu.zip .\Ubuntu
4: Launch the setup file
Now you are going to launch the files by the command below:
C:\Linux\Ubuntu, \Ubuntu2004.exe
Loading will take place, this might take a while. After the installation, a prompt will appear that will ask you to create a new user and assign it a password.
NOTE: this is not a root user, so make sure the user name is in lower case only.
5: Update on Linux
Here you are going to update your package catalog with Sudo apt update and if you are on Ubuntu/Debian then you will use Sudo apt upgrade. Make sure you are using the sudo, to avoid any issue during the installation.
Soon you will receive a prompt asking for the password of the account that you have created recently.
6: Set WSL 2 on Windows Server
Now that you are here, it means that you have successfully completed almost 94% of the tasks. Here you are going to give it the final touch which will set the Linux distro which is our topic here “install WSL2 on Windows Server 2019”.
To change the version of the Linux distro, you will use the command below:
wsl --set-version Ubuntu-2004
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.
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:
- Windows Server 2022 June cumulative update or 5c preview update (May)
- A machine that supports Hyper-V Virtualization.
- If you are installing your Windows Server in a virtual machine, make sure Nested Virtualization is enabled.
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.
This will also download Ubuntu as for your WSL 2 Linux distro.
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.
Tags: Hyper-V, install, installation, Microsoft, Windows Server, Windows Server 2019, Windows Server Insider Preview, Windows Subsystem for Linux 2, Windows Subystem for Linux, WSL, WSL 2, WSL 2 on Windows Server, WSL on Windows Server Last modified: May 31, 2022
About the Author / Thomas Maurer
Thomas works as a Principal Program Manager & Chief Evangelist Azure Hybrid at Microsoft (Cloud + AI). He engages with the community and customers around the world to share his knowledge and collect feedback to improve the Azure hybrid cloud and edge platform. Prior to joining the Azure engineering team (Cloud + AI), Thomas was a Lead Architect and Microsoft MVP, to help architect, implement and promote Microsoft cloud technology.
If you want to know more about Thomas, check out his blog: www.thomasmaurer.ch and Twitter: www.twitter.com/thomasmaurer
Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux executable binaries (ELF format) natively on Windows 10, Windows 11, and Windows Server 2019. In May 2019, WSL2 was announced. It introduces major changes like a true Linux kernel through a subset of Hyper-V features. As of June 2019, WSL2 is only available to Windows 10 customers, including Home editions, through the Windows Insider Program. Not every Windows 10 user has WSL available by default. You can install it by joining the Windows Insider Program or by installing it manually on your Windows Server 2019.
WSL 1’s design does not include hardware emulation/virtualization (unlike other projects like coLinux). For example, a web server can be accessed through the same interface and IP address configured on the host and has the same restrictions on using ports that require administrative privileges or are already occupied by other applications. There are certain locations (e.g. system folders) and configurations that are restricted to access/modify even when running as root with sudo from a shell. To give “sudo” true root privileges and allow such access, you need to start an elevated instance.
Installing WSL Feature On Windows Server 2019
In order to install Linux Distro, you have to enable the Windows Subsystem for Linux (WSL) feature from Windows Server Manager or PowerShell.
Browse to Windows Server Manager/Add roles and features, in the featurre window install the WSL option and reboot the server.
Or Open the Windows PowerShell and enter the given command to enable this feature via CLI. As I have already installed the WSL feature the PowerShell will give output for given command as, Online:True.
# Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Installing Virtual Machine Platform Feature
Virtual Machine Platform is a non-powerful version of HyperV, but it still allows you to use your hypervisor. VMP is a requirement of WSL1&2 (Windows Subsystem for Linux) and is very good. This is used to create his MSIX application package for App-V or MSI. Type in the given command in PowerShell as an Administrator to install VMP and restart the server if the output prompts.
# dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Installing Linux Kernel Update Package
Windows Subsystem for Linux Kernel Update Package contains Linux Kernel Update Package to upgrade Windows 64-bit to WSL (Windows Subsystem for Linux), so you can install Linux on a Windows server. Use the given link to download the Linux Kernel Update Package and install it. Restart the server.
Installing The Linux Distribution of your choice
There are several ways to install the WSL Linux distro from the Microsoft Store. This guide uses the PowerShell approach to download and install WSL. Launch PowerShell and type in the given command to list available distros. This is a sample guide for downloading Ubuntu 20.04.
# wsl –list –online
Now type in the given command to install Ubuntu 20.04 LTS. This will take some time depending on your network connection. This will install the Ubuntu distro and create a shortcut in the start menu with the Distro name.
# wsl –install -d Ubuntu 20.04 LTS
That’s it Windows Subsystem For Linux is installed. Click on the given app icon to access the Distro and set up the username and password. These are the two GUI apps that I have opened in my WSL. You can open them too.
Conclusion
WSL can help organizations achieve seamless integration with their WSL deployments. Contact us to learn more about how Windows Subsystem for Linux can support your business. What you never thought is now possible on Windows.
Did you try to install WSL2 on Windows Server 2019 through wsl --install
?
Did you try to install Microsoft Store?
Unfortunately it doesn’t work on Windows Server 2019.
But it has soluction.
The solution was based on the link below:
- Microsoft;
Just follow the steps:
Those steps below needs to be done other and Administrator
cd C:\Users\Administrator\
Enter fullscreen mode
Exit fullscreen mode
Enable the Windows Subsystem for Linux
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enter fullscreen mode
Exit fullscreen mode
Download a Linux distribution
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing
Enter fullscreen mode
Exit fullscreen mode
Extract and install a Linux distribution
Rename-Item .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip .\Ubuntu
Enter fullscreen mode
Exit fullscreen mode
Add your Linux distribution path to the Windows environment PATH
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")
Enter fullscreen mode
Exit fullscreen mode
Start installation (change directory to directory where is ubuntu.exe)
ubuntu.exe
Enter fullscreen mode
Exit fullscreen mode
If is it usefull, please leave your comment or suggestion.
If it doesn’t work, let’s try together
Узнайте, какие версии Windows Server совместимы с подсистемой Windows для Linux (WSL). Согласно последним рекомендациям Microsoft, вы можете запускать Linux на Windows Server 2019 с ВСЛ. Эта совместимость распространяется на несколько выпусков Windows Server Semi-Annual Channel (SAC), включая версии 1909, 2004, 20H1, 20H2 и более позднюю версию Windows Server 2022.
Содержание:
- Узнайте, как запустить Linux на Windows Server 2019 с помощью WSL
- Процесс установки WSL на Windows Server
Для тех, кто заинтересован в запуске приложений Linux с графическим интерфейсом через WSL, есть полезное руководство под названием «Как установить приложения Linux с графическим интерфейсом в Windows 10 и Windows 11 с помощью WSL»доступно на Петри. Этот ресурс предоставляет пошаговый подход к улучшению вашего опыта работы с WSL.
Процесс установки WSL на Windows Server
Процесс установки WSL на Windows Server представляет собой интригующую перспективу, прежде всего потому, что процедура различается в зависимости от конкретной используемой версии Windows Server. Одним из заметных отличий является поддержка или отсутствие таковой дистрибутивов WSL 2 в Windows Server 2019 и 2022. Это существенное отличие по сравнению с установкой в Windows 10 и 11.
Однако, помимо этого ключевого момента, общий опыт использования WSL на Windows Server аналогичен таковому в Windows 10 или 11. Этот процесс аналогичен настройке Hyper-V на этих платформах. Точно так же, как вы включаете Hyper-V и используете диспетчер Hyper-V для создания виртуальных машин в Windows 10 и 11, WSL обеспечивает плавный переход между его использованием в клиентских системах Windows и средах Windows Server.
Начало работы с WSL в Windows
Активация WSL в вашей системе
Чтобы начать процесс использования дистрибутивов Linux через WSL, первым делом нужно активировать «Подсистема Windows для Linux» на вашем компьютере.
- Через PowerShell: откройте PowerShell с правами администратора и введите следующую команду, чтобы включить функцию WSL в Windows:
- Скопировать код
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Подтвердите и продолжите перезагрузку системы, когда будет предложено убедиться, что изменения применены.
- Через диспетчер сервера (для пользователей сервера): если вы работаете с сервером, того же результата можно добиться графически. Перейдите в Диспетчер серверов, выберите «Добавить роли и функции», затем перейдите в раздел «Функции», чтобы включить WSL.
Эти шаги закладывают основу для установки предпочитаемых вами дистрибутивов Linux в подсистеме Windows для Linux, упрощая интеграцию сред Windows и Linux на вашем компьютере.
Запуск предпочитаемого вами дистрибутива Linux с помощью WSL
После включения подсистемы Windows для Linux (WSL) следующим шагом будет выбор и установка желаемого дистрибутива Linux. В этом разделе описывается весь процесс с использованием командной строки, уделяя особое внимание непосредственному приобретению дистрибутива Linux.
Загрузка и установка дистрибутива Linux через командную строку
- Получите свой дистрибутив Linux
Начните с открытия PowerShell. Вы можете загрузить выбранный вами дистрибутив Linux с помощью командлета Invoke-WebRequest или Curl.exe. Например, чтобы загрузить Ubuntu 20.04, вы должны использовать следующую команду:
«`
curl.exe -L -o ubuntu-2004.appx https://aka.ms/wslubuntu2004
«`
- Подготовьте и установите дистрибутив
После загрузки вам необходимо подготовить файл к установке:
– Переименуйте загруженный файл в формат .zip для извлечения:
«`
Rename-Item ubuntu-2004.appx ubuntu-2004.zip
«`
– Извлеките содержимое zip-файла:
«`
Expand-Archive ubuntu-2004.zip ubuntu2004
«`
– Перейдите в извлеченный каталог и запустите исполняемый файл установки:
«`
cd ubuntu2004
.\ubuntu2004.exe
«`
Во время установки вам будет предложено создать имя пользователя и пароль UNIX. Этот шаг необходим для обеспечения безопасности вашей новой среды Linux.
Настройка и обновление среды Linux
После установки рекомендуется обновить и установить необходимые пакеты:
– Обновите список пакетов вашей системы и обновите все установленные пакеты до последних версий:
«`
sudo apt update && sudo apt upgrade
«`
– Чтобы установить дополнительные инструменты или программное обеспечение, используйте команду apt install. Например, установка Ansible:
«`
sudo apt install ansible
«`
Интеграция вашего дистрибутива Linux в среду Windows
Чтобы беспрепятственно управлять своим дистрибутивом Linux из любого места в PowerShell, добавьте путь к дистрибутиву в PATH среды Windows. Это можно сделать с помощью следующих команд PowerShell:
«`
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\ubuntu2004", "User")
«`
После обновления PATH вам потребуется перезапустить PowerShell, чтобы применить изменения. Теперь вы можете запустить дистрибутив Linux непосредственно из любого каталога, введя имя его исполняемого файла, например `ubuntu2004.exe
`.
Эта установка обеспечивает гибкую и интегрированную среду для запуска Linux вместе с вашим Windows Server, предлагая лучшее из обоих миров для разработчиков и системных администраторов.