How to run Linux distro app as WSL 2 running on WSL 1

WSL 2, an upgraded version of popular WSL 1 with full Linux kernel support and other fixes. The best thing it will be the part of Windows 10 for everyone after the 2004 feature update slated for May 2020, however, if you are a Windows insider preview user than you can test it. So, here we will show you how to convert WSL 1 Linux running app to WSL 2 after enabling it on your system (Windows 10 Insider).

How to setup of WSL 2 on Windows.

It doesn’t matter you want to use WSL 1 or WSL 2, the first thing we have to do is enabling its services through the “Turn Windows feature on or off“.

Step 1. Go to Windows 10 Search box and type “Turn Windows feature on or off”

Step 2. As it appears, click to run it.

Step 3. Scroll down and check the box of “Windows Subsystem for Linux”.

Step 4. Further, if we want to use WSL 2, then we have to enable one more service called “Virtual Machine Platform“. If we don’t then later while converting WSL 1 running Linux apps to run on WSL 2 we will get an error “Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS“.

Enable WSL 2 on Windows 10

Enable WSL 2 on Windows 10

Step 5. Finally, reboot the system.

Trivial info: You can also simply use the below command in PowerShell by running it under administrative rights.

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

Step 6. One more thing which we have to do to run WSL 2 properly is the adding Kernel components otherwise we will get an error “WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel” while working with WSL2. So, either go to Microsoft’s WSL2 Kernal Update page or simply click on this link to download the latest WSL2 Linux kernel update package for x64 machines.

Step 7. Run the downloaded package, it will ask you for the administrator rights to install. Give it.

Step 8: Now, open PowerShell as admin. For that simply right click on the Windows 10 start button and select Windows PowerShell (Admin) option.

Step 9: I am assuming that you already have installed some Linux app from Microsoft Store. If no than open it and install any of the available Linux distro apps such as Debian, Ubuntu and more. Here I have Ubuntu 20.04 and Ubuntu 18.04 installed on WSL 1, now I want to move them to WSL 2, so for that, the command will be:

First, let’s check the installed Linux distros on WSL 1:

Type:

 wsl -1

In my case, I have Ubuntu 18.04 and Ubuntu 20.04, thus it has shown the same.

PS C:\WINDOWS\system32> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu-18.04
PS C:\WINDOWS\system32>

Now, I want to run Ubuntu-18.04 on WSL 2, so for that, I need to type a command to initiate the conversion process:

wsl --set-version Ubuntu-18.04 2

In the above command just change the Ubuntu-18.04 with your available WSL1 Linux distro app.

The conversion process may take a few minutes depending upon the service running on it and the total size it would have.

Convert and Run WSL 1 Linux app on WSL 2

Convert and Run WSL 1 Linux app on WSL 2

Step 10: To check which version of WSL is running by your installed Linux distro apps simply run the following command:

wsl -l -v

I have both on WSL 2, thus same the result was…

Cherck which WSL version you are running

Check which WSL version you are running

Use Docker images on WSL 2

We can easily set up and use Docker and its images in our WSL 2 environment.  Although the setting of it is possible on WSL 1 as well, running on Windows Subsystem for Linux (WSL) 2 give it is a full Linux kernel. It means Linux containers can run natively rather emulating themselves. This gives leverage to developers, as they don’t need to install Docker running Linux distro on Windows separately to work, now they can easily integrate it with existing WSL 2 running distro.

See: Ubuntu 20.04 it becomes super easy, as we just need to use one single command to setup Docker.

WSL 2 provides improvements to file system sharing, boot time and allows access to some cool new features for Docker Desktop users. Therefore, developers who want to start occasional background services such as Docker or Apache on their development system, WSL 2 is a suitable option on WIndows 10. When installing packages in a WSL2 environment, you can feel that the new approach delivers better performance; With WSL1, such processes feel really tough.

 

Leave a Reply

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