Home / Linux / How To Install and Use Windows Subsystem for Linux 2 — Virtualization Review

How To Install and Use Windows Subsystem for Linux 2 — Virtualization Review

How To Install and Use Windows Subsystem for Linux 2

Now that it’s been released with the latest Windows 10 Insider Preview build, find out how to install, enable and use WSL 2.

Yesterday (June 12, 2019) Microsoft released Windows 10 Insider Preview Version 1903 Build 18917.1000. This is the first Windows build that has the second generation of Windows Subsystem for Linux (WSL 2) included in it. I wrote another article detailing what WSL 2 is and why it is such an important development for Microsoft’s users. In this article, I’ll show you how to enable WSL 2, how to install a Linux distro that can use WSL 2, show you some new switches that can be used with the wsl command, and then share my final thoughts on WSL 2.

Installing WSL 2
After downloading the latest Microsoft Insider build (read my article on how to do that here) I verified that build 18917.1000 was installed by entering winver at the command prompt (Figure 1).


[Click on image for larger view.]
Figure 1. Using Winver to ensure the latest build is installed.

I then brought up Control Panel and selected Programs, then Turn Windows features on or off, and then made sure Virtual Machine Platform and Windows Subsystem for Linux were selected (Figure 2). Next, I rebooted my system.


[Click on image for larger view.]
Figure 2. Enabling WSL 2.

I brought up an Administrator Windows console and entered wsl –list and was informed that WSL had no installed distributions and I should visit the Microsoft Store to download one (Figure 3). From this site I downloaded and installed Ubuntu and then clicked Launch.


[Click on image for larger view.]
Figure 3. Downloading Ubuntu on Windows.

When I launched Ubuntu in WSL I was asked to set a user and password, but I noticed that it was still running under WSL 1, so I exited out of my Ubuntu console.

To convert Ubuntu to WSL 2 from my console I entered wsl -list and saw that Ubuntu was now listed. I set WSL 2 as my default WSL environment by entering wsl –set-default-version 2 and then entered wsl –set-default-version Ubuntu 2 to convert Ubuntu to use WSL 2 . After a few minutes I was informed the conversion was complete (Figure 4).


[Click on image for larger view.]
Figure 4. Converting Ubuntu to use WSL 2.

From the console I entered wsl -d Ubuntu and brought up Ubuntu running under WSL 2 (which runs Linux in a lightweight virtual machine). I did notice that Ubuntu seemed more responsive under WSL 2 than under WSL 1. To verify that I was using WSL 2 I brought up the Windows Task Manager and verified that Vmmem was running (Figure 5). Vmmem is a process used by VMs, such as WSL 2.


[Click on image for larger view.]
Figure 5. Verifying that the Vmmem process is running.

New WSL Commands
Microsoft included new switches for the wsl command with this release. As you saw earlier, I used the wsl –set-default-version switch to set the default WSL environment and convert a WSL 1 Linux image to WSL 2. Here are some of the other switches that can now be used with the wsl command:

wsl –shutdown will immediately terminate all running distributions and the WSL 2 VM on which they run.

wsl –list –quiet will only list the distribution names, no other information (Figure 6). This will be useful with scripts.


[Click on image for larger view.]
Figure 6. The wsl –list –q switch.

wsl –list –verbose will show detailed information about all the distributions installed on your Windows system. This information includes what state the distro is in, and what version it’s running, and the default distro will be marked with an asterisk “*” (Figure 7).


[Click on image for larger view.]
Figure 7. The wsl –list –v.

To further test the new WSL switches I downloaded and installed Debian from the Microsoft Store and instantiated it with out converting it to WSL 2 and wsl -l -v did show that it was running under WSL 1.


[Click on image for larger view.]
Figure 8. WSL 1 and WSL 2 distros.

Wrapping Up
Installing and getting WSL 2 to run on my system took less than 15 minutes and only a single reboot. I applaud Microsoft for taking the bold step of abandoning WSL 1 in favor of WSL 2 as WSL 2 will have greater compatibility and will support more use cases.

From my limited testing WSL 2 seemed to respond quicker; however, Microsoft has warned that WSL 2 has issues with networking. (Because WSL 2 runs in a VM, that VM’s IP address needs to be used to access Linux networking applications from Windows, and vice versa — you’ll need the Windows host’s IP address to access Windows networking applications from Linux. Microsoft plans to have the ability for WSL 2 to access network applications with localhost as soon as possible, according to a Microsoft blog post.)

Issues such as these are not unexpected in an early release and I’m sure that they’ll be worked out by the time WSL 2 is included in a Windows 10 release for the general public. I’m looking forward to working with and investigating WSL 2. For a full list of changes between WSL 1 and WSL 2, you can read the Microsoft 

support article
on it.

About the Author



Tom Fenton works in VMware’s Education department as a Senior Course Developer. He has a wealth of hands-on IT experience gained over the past 20 years in a variety of technologies, with the past 10 years focused on virtualization and storage. Before re-joining VMware, Tom was a Senior Validation Engineer with The Taneja Group, were he headed their Validation Service Lab and was instrumental in starting up its vSphere Virtual Volumes practice. He’s on Twitter @vDoppler.

Loading...

>> Source Link

Check Also

The Linux Foundation Will Host the Federated AI Enabler to Responsibly Advance Data Modeling

WeBank to contribute the Federated AI Enabler framework to the Linux Foundation and establish neutral …