Wsl2 windows server 2016

Одним из новшеств Windows Server 2016 версии RedStone 3 (1709) является встроенная поддержка запуска нативных бинарных файлов Linux ELF64. Данный функционал реализуется за счет отдельного компонента Windows Subsystem for Linux (WSL), который обеспечивает нужный слой совместимости. В этой обзорной статье мы покажем, как включить подсистему Windows для Linux в Windows Server 2016 и использовать ее для запуска Linux приложений.

Возможность запуска Linux приложений в Windows ранее была представлена в Windows 10. Эта функция носила название Bash on Windows. Начиная с Windows 10 Fall Creators Update это название более не используется и официально эта подсистема теперь называется WSL — Windows Subsystem for Linux. Кроме того, для ее использования более не нужно переключать ОС в режим разработчика (Developer Mode). WSL доступна как Windows Server, так и в виртуальных машинах Microsoft Azure

Предполагаем, что вы уже скачали и установили релиз Windows Server >= 1709. Это может быть сервер с полноценным GUI или в Core режиме.

Проверить текущую версию ОС можно так:

systeminfo | Select-String "^OS Name","^OS Version"

Чтобы проверить, что в вашей версии Windows Server имеется функционал WSL, выполните следующую команду:

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

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

Чтобы включить поддержку подсистемы Linuх, выполните команду:

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

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

После чего сервер нужно перезагрузить.

Далее необходимо скачть архив с адаптированным дистрибутивом Linux. На данный момент Microsoft предлагает поддержку следующих дистрибутивов:

  • Ubuntu – https://aka.ms/wsl-ubuntu-1604
  • OpenSUSE – https://aka.ms/wsl-opensuse-42
  • SLES – https://aka.ms/wsl-sles-12 — корпоративный вариант SUSE

В ближайшем будущем планируется добавить дистрибутивы CentOS и Fedora.

К примеру, с помощью PowerShell по HTTP протоколу, скачаем архив с дистрибутивом Ubuntu:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile ~/Ubuntu.zip -UseBasicParsing

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604

Размер архива около 200 Мб. Распакуем его:

Expand-Archive ~/Ubuntu.zip ~/Ubuntu

Expand-Archive ~/Ubuntu.zip ~/Ubuntu

Исходный архив можно удалить:

Remove-Item Ubuntu.zip

Для запуска установки дистрибутива достаточно запустить файл:

Ubuntu.exe

Запустится мастер установки, который в том числе попросит указать имя пользователя и пароль, который вы будете использовать для доступа к середе Linux (эта учетная запись не связана с Windows и входит в группу sudoers, таким образом ей разрешено использовать команду sudo для установки пакетов)

Ubuntu.exe

Запустим обновление дистрибутива:

sudo apt-get update
sudo apt-get upgrade

Чтобы выйти из командой оболочки Linux и вернуться в PowerShell, наберите:

Exit

Открыть shell в любой момент можно командой:

bash

Имеется возможность запускать команды Linux из консоли Windows и наоборот. К примеру, в консоли PowerShell можно вывести список файлов в каталоге командой ls. Формат команды должен быть такой:

bash -c “ls -la”

Запуск команд Linux из Windows

Чтобы из Linux вызвать команду Windows, формат должен быть такой:

cmd.exe /c dir

Примечание. Обратите внимание, что при запуске исполняемых файлов Windows нужно обязательно указывать расширение и соблюдать регистр имени оригинального файла.

Запуск команд Windows из Linux

Нужно отметить, что из Linux можно запускать только те исполняемые файлы Windows, которые описаны в специальной переменной окружения. Чтобы добавить в переменную окружения новый путь, выполните команду:

export PATH=$PATH:/mnt/c/Windows/System32

Теперь можно вызвать любой файл из каталога %WinDir%\system32.

run notepad.exe from linux

Чтобы передать параметр на вход исполняемого файла, нужно воспользоваться такими конструкциями:

$notepad.exe “C:\temp\test.txt”
$notepad.exe C:\\temp\\test.txt

Все исполняемые файлы в этом случае запускаются в контексте учетной записи, запустившей bash.exe.

Итак, подсистему WSL можно использовать для тестирования, разработки и запуска утилит Linux, недоступных в Windows окружении без необходимости развертывать и настривать отдельную виртуальную машины с Linux.

How-To

Hands-On with WSL: Installing Windows Subsystem for Linux on Windows Server

The recent release of Windows Server 2016 version 1803 allows WSL to be installed on it. Tom Fenton steps you through the process.

Windows Subsystem for Linux (WSL) has been available for Windows 10 since 2017, and in a previous article I showed you how to install WSL on Windows 10. The recent release of Windows Server 2016 version 1803 (released April 30, 2018) allows WSL to be installed on it, and in this article I’ll show you how.

Although WSL is now available for Windows Server, getting a build of Windows that supports WSL can be challenging as the only production versions of Windows Server that are currently available to most users are pre-1803 builds (Figure 1). In order to get a version of Windows Server that supports WSL, you need to be either running a Windows Insider Program for Business or using a Semi-Annual Channel build, which is only available to Software Assurance or Microsoft Cloud customers.

[Click on image for larger view.]
Figure 1. The supported versions of Windows Server.

I used my Windows Insider Account to download Windows Server Insider preview build 17650, and installed it as a virtual machine (VM) with 2 vCPUs and 8GB of RAM on vSphere 6.5. After Windows Server was installed, I verified that I was running a version of it that supports WSL by entering winver from the command line. Figure 2 shows the results.

[Click on image for larger view.]
Figure 2. After entering winver into the command-line, this dialog window shows what version of Windows Server is running.

Like many other features, WSL can be installed from the Server Manager. To do this, bring up the Server Manager, then take the following steps: select Add roles or features, select Role-based or feature-based installation, select your local server and then click Next on the Select Server Roles page. On the Select features page select Windows Subsystem for Linux (Figure 3) and, finally, on the confirmation page click Install. I had to restart my system after WSL had finished installing.

[Click on image for larger view.]
Figure 3. WSL feature.

After restarting my server, I logged back in and entered WSL on the command prompt and was informed that WSL was working but no Linux distributions were installed (Figure 4). It instructed me to go to https://aka.ms/wslstore; however, this message appears to be an error as this Web site does not exist. Alternatively, I was able to enter https://aka.ms/wsl-ubuntu-1604 on my Web browser and download Ubuntu for WSL. If you want to download OpenSuse, use the URL https://aka.ms/wsl-opensuse-42, and for SLES 12, use the URL https://aka.ms/wsl-sles-12.

[Click on image for larger view.]
Figure 4. There’s no Web site for this URL.

Once the Ubuntu file was downloaded, I extracted it and double clicked ubuntu; when presented with a dialog indicating Windows Defender SmartScreen prevented an unrecognized app from starting, I clicked Run anyway (Figure 5). It took few minutes to install, and I was then presented with a prompt to enter a user and set the user’s password (Figure 6).

[Click on image for larger view.]
Figure 5. Installing Ubuntu.
[Click on image for larger view.]
Figure 6. Setting the new user’s password.

Once Ubuntu had finished installing and I had created a user, I could then enter wsl on the command prompt and use the WSL bash shell to perform various functions. To see some of the things that you can do with WSL, be sure to read my articles about executing daily tasks, running graphical apps and other features and apps that work with WSL.

About the Author


Tom Fenton has a wealth of hands-on IT experience gained over the past 30 years in a variety of technologies, with the past 20 years focusing on virtualization and storage. He previously worked as a Technical Marketing Manager for ControlUp. He also previously worked at VMware in Staff and Senior level positions. He has also worked as a Senior Validation Engineer with The Taneja Group, where he headed the Validation Service Lab and was instrumental in starting up its vSphere Virtual Volumes practice. He’s on X @vDoppler.

INTRODUCTION

Windows Subsystem for Linux (WSL) is a feature of Windows that allows developers to run a Linux environment without the need for a separate virtual machine or dual booting. There are two versions of WSL: WSL 1 and WSL 2. WSL 1 was first released on August 2, 2016, and acts as a compatibility layer for running Linux binary executables (in ELF format) by implementing Linux system calls on the Windows kernel. It is available on Windows Server 2016, 2019 and 2022. In this tutorial, we will learn how to enable Windows Subsystem for Linux (WSL) feature to use Linux on Windows Server 2016, 2019 and 2022.

Prerequisites

  • Windows Server

  • PowerShell with Administrator rights

  • Internet connectivity

Step 1. Login to your Windows Server

Step 2. Open PowerShell as an Administrator

Step 3. Run the following command to enable Windows Subsystem for Linux

enable Windows Subsystem for Linux

enable Windows Subsystem for Linux

Step 4. In this tutorial, we will be creating the subsystem for Ubuntu.

Run the following command to download Ubuntu 18.04

enable Windows Subsystem for Linux

enable Windows Subsystem for Linux

Step 5. Enter new UNIX username: (to create a new user)

Enter the password for the user.

Installation successful.

Step 6. Windows resources are mounted on [/mnt/c] which can be accessed by

enable Windows Subsystem for Linux

Step 7. To access Linux resources with root priviledge, us sudo command

enable Windows Subsystem for Linux

Thank You!

In 2017 Microsoft made it possible to run different Linux distribution on Windows 10, using a feature called the “Windows Subsystem for Linux“. With the latest official Semi-Annual Channel Windows Server release called Windows Server, version 1709 Microsoft also allowed to run the Windows Subsystem for Linux (WSL) on Windows Server. With the next release of Windows Server called Windows Server, version 1803, Microsoft will also add some improvements to the Windows Subsystem on Linux, which also apply to Windows 10 as well as Windows Server. This blog post shows you how you can do this.

First, you have a Windows Server, version 1709 running. After that enable the Microsoft Windows Subsystem for Linux feature, running the following command (This will need a reboot)

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

You can download the appx packages for your favorite Linux distribution; this can be today:

  • Ubuntu
  • OpenSUSE
  • Suse Linux Enterprise Server

If you are running on Windows Server Core (which is highly likely), you can use the following command to download the Linux distributions.

# For Ubuntu 16.04
 
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile ~/Ubuntu.zip -UseBasicParsing
 
# For Ubuntu 18.04
 
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu1804.zip -UseBasicParsing
 
# For OpenSUSE 42
 
Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile ~/OpenSUSE.zip -UseBasicParsing
 
# For SLES 12
 
Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile ~/SLES.zip -UseBasicParsing

You can then unpack the file:

Expand-Archive ~/Ubuntu.zip C:\Distros\Ubuntu

Now you can open that folder and run the installer, for example ubuntu.exe. The first time this will do the setup where you also define the UNIX username and password as well as the root password.

After that, you can run updates for your distro, and you can start using Linux.

If you want to know more about the WSL, check out the Microsoft Documentation: Windows Subsystem for Linux Documentation and have a look at my WSL post in for Windows 10: Crazy times – You can now run Linux on Windows 10 from the Windows Store

You can also find the other Linux distro packages here: WSL distro packages.

Tags: Linux, Microsoft, openSUSE, PowerShell, SLES, Ubuntu, Ubuntu on Windows Server, Ubuntu.exe, Windows, Windows 10, Windows Server, Windows Server 1709, Windows Subsystem for Linux, WSL Last modified: June 20, 2019

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

Microsoft has rolled out its latest Windows Server preview build for PC users. The company released build 16257 on the Windows Insider Program. The major talking point about this Redstone 3 build is it comes with Windows Subsystem for Linux (WSL) integrated.

Windows Server has recently moved into the same update model as Windows 10. For the latter, Microsoft has been treating Windows 10 as a service. This means regular updates with new features, as well as fixes. Windows Server was moved to the same model last month, letting users test new features before they launch.

With WSL now built in, Windows Server users get the compatibility layer for running Linux binary executables on Windows. This important for developers and admins who run Linux alongside Microsoft tools like PowerShell.

Microsoft launched WSL with the Windows 10 Anniversary Update, but it comes to Server for the first time.

In its announcement, the company explained how WSL works:

“If you’re a server engineer that needs to run node.js, Ruby, Python, Perl, Bash scripts or other tools that expect Linux behaviors, environment or filesystem-layout, the ability to install and run Linux with WSL expands the tools at your disposal on Windows Server.

Just as with WSL on Windows Client, you can run daemons and jobs like MySQL, PostgreSQL, sshd, etc., via an interactive shell, but you cannot currently use WSL to run persistent Linux services, daemons, jobs, etc. as background tasks.”

More Features

Preview Build 16257 also comes with Remote Server Administration Tools (RSAT). This feature gives users the ability to remotely manage Windows Server builds on the Inside. For this addition, users will need to be running Windows 10 Fall Creators Update (Redstone 3) 16250 or higher.

Microsoft also confirmed today it is using Delivery Optimization as its update tool for Windows Server. Windows Update has been using the feature since the Anniversary Update. It allows peer-to-peer bandwidth optimization.

Luke Jones

Luke has been writing about Microsoft and the wider tech industry for over 10 years. With a degree in creative and professional writing, Luke looks for the interesting spin when covering AI, Windows, Xbox, and more.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Можно ли установить sql server на windows 10
  • Trim check windows 10
  • Проблема с восстановлением системы windows 10
  • Tuneup utilities для windows 10 portable
  • Как узнать системные требования ноутбука на windows 10