Install wsl2 and master linux on windows


It is inside. In the previous article, I introduced the procedure Enable windows subsystem for linux (WSL1) which became a standard function of windows 10 to run kali linux. .. This time I would like to enable WSL2 which can be used in "Windows 10 Insider Preview Build" released on June 12 and use ubuntu.

As usual, we will emphasize ** awareness ** rather than comprehensibility, and introduce it in a way that does not use the GUI as much as possible.

Reasons to include WSL2

** Software that did not work on WSL1 works! ** **

I mentioned in the previous article that WSL1 will not be able to run all software on Linux, but the Linux kernel is not working mechanically, and a function call to the kernel is made to lxcore.sys. And lxss.sys are working by converting them into function calls to the Windows kernel, and the incomplete implementation of system calls for these kernel drivers is also due to some software not working. In that respect, WSL2 runs the ** Linux kernel on ** Hyper-V, so most programs will run.

WSL2 Other features

--nmap and tcpdump that couldn't be used with wsl1 are now working. --If you use wsl2, wsl1 will not be disabled, and you can select it for each OS you run on. For example, kali-linux can be run on wsl1 and ubuntu-18.04 can be run on wsl2. --You can convert ubuntu originally installed in wsl1 to wsl2 with the wsl command. --Since wsl1 is running on windows, the IP address seen from the linux side was shared with the ip address on the windows side, Since wsl2 runs on the vm and the network components are also virtualized, it is assigned a different IP address than the windows host. --Until now, enabling hyper-v on windows 10 was only possible with windows 10 Pro or Enterprise, The hyper-v based virtualization technology for wsl2 is now available at Home as well. Instead, if Hyper-v is used, VMWare and VirtualBox 6 and earlier versions cannot be executed. --It's easy to speculate that startup would have been slower because of virtualization, but it's rather faster.

Prerequisites for wsl2 installation

--Because it uses Hyper-V technology, it is necessary to meet the requirements of Hyper-V, such as 64-bit version and virtualization technology support at the BIOS level. --Install "Windows 10 Insider Preview Build".

Installation procedure

First of all, system backup

As of March 2020, WSL2 is only available in the "Windows 10 Insider Preview Build", and WSL2 will be available as the default feature from the feature update version provided in May 2020.

In the first place, "Windows 10 Insider Preview Build" is a mechanism to quickly obtain the functions currently under development that will be released as a stabilizer in the future, so there is a trade-off that stability will be lost. In fact, since I installed the Preview build and used wsl2, I've experienced many times that windows itself restarts automatically due to a bug that hasn't happened before. ** **

So, first of all, make a backup of your system.

Install Windows10 Insider Preview build

  1. [Settings]
  2. [Update and Security]
  3. [Windows Insider Program] Select to access the latest build by clicking Start. Follow the instructions to receive the preview and restart.

This procedure is on microsoft official, so install the Preview build quickly.

** Point: By default, the frequency of receiving preview builds is "fast ring", This means that new features will be installed on a weekly basis after that, and the computer will be updated and restarted each time. It is recommended to select slowing (every month) as it will increase the amount of time it will be unavailable. ** **

After that, launch a command prompt and check that it is Windows 10 build 18917 or later with the following command.

command prompt:


Microsoft Windows [Version 10.0.19037.1]

Enable windows virtualization feature for wsl2 to work

Run powershell as administrator. powershell.png

And below, execute the command to enable the virtualization function of windows

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Please restart your computer for activation after execution.

If you are enabling wsl for the first time, including wsl1, ** Enter the following command in the started powershell. ** **

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

Install ubuntu on wsl2

All you have to do is launch the microsoft store, search for ubuntu and perform the installation. This time, I added the Ubuntu 18.04 LTS version. command prompt:

C:\Users\uchi>start ms-windows-store:

Convert the installed ubuntu to wsl2. When installed, the ubuntu version of wsl is 1, so start powershell and convert it to 2.

** Check wsl version ** powershell:

PS C:\Users\uchi> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         1
  kali-linux      Stopped         1

** Version conversion ** powershell:

PS C:\Users\uchi> wsl --set-version Ubuntu-18.04 2

** Reconfirm wsl version ** powershell:

PS C:\Users\uchi> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         2
  kali-linux      Stopped         1

Now you can run kali-linux on wsl1 while running Ubuntu-18.04 on wsl2.

Left: Running tcpdump on kali linux on wsl1 and failing diagram Right: Figure of executing tcpdump with ubuntu-18.04 on wsl2 wsl1_2.png

The source of wsl2's linux kernel is released on github below. WSL2-Linux-Kernel

Summary of steps to install wsl2 on Windows

--If you use wsl2, you will be able to use various commands and programs that were not available in wsl1. ――But at the moment, it is only provided in Windows 10 Insider Preview build, so windows will be unstable. ――So take a backup. ――Wsl1 and 2 can live together, so it's convenient to use them properly.

Recommended Posts

Install wsl2 and master linux on windows
Linux (WSL) on Windows
Use Linux on Windows 10 (WSL2)
(Windows10) Install Linux environment and gnuplot.
WSL2 ~ Linux on Windows ~ (Part 1: Introduction)
Build and install OpenCV on Windows
Install easy_install and pip on windows
[UE4] Build DedicatedServer on Windows and Linux
Install and launch k3s on Manjaro Linux
Install and Configure TigerVNC server on Linux
Install Puppet Master and Client on Ubuntu 16.04
Install python on WSL
Install Anaconda on Windows 10
Install python on windows
Install pycuda on Windows10
Install pygraphviz on Windows 10
Install Chainer 1.5.0 on Windows
Install and run Python3.5 + NumPy + SciPy on Windows 10
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Organize files on Windows with Linux commands-using WSL-
Install ZIP version Python and pip on Windows 10
Build Linux on a Windows environment. Steps to install Laradock and migrate
Install Numpy on virtualenv on Windows
Install Minecraft on Arch Linux
Install Linux on your Chromebox
Install Python and Flask (Windows 10)
Install cvxpy on windows, Anaconda
Install the JDK on Linux
Recording and playback on Linux
[Windows] [Python3] Install python3 and Jupyter Notebook (formerly ipython notebook) on Windows
Install Chainer 1.6 (GPU) on Windows 7.
wsl Install PostgreSQL on Ubuntu 18.04
Linux on Windows -1-: debian introduction
Install tomcat 5.5 on Amazon Linux.
Compile and install MySQL-python for python2.7 on amazon linux
Install Docker on Arch Linux and run it remotely
Install Homebrew on Amazon Linux 2
Install Docker on WSL Ubuntu 18.04
Install strongSwan 5.9.1 on Amazon Linux 2
[Python] [Chainer] [Windows] Install Chainer on Windows
Linux environment construction (on WSL environment)
Install procs, an alternative tool for ps, on Linux (also available on Mac and Windows)
Install LAMP on Amazon Linux 2 and build a WordPress environment.
Install python and Visual Studio Code on windows10 (April 2020 version)
Differences between Windows and Linux directories
Python 3.6 on Windows ... and to Xamarin.
Install Mecab and mecab-python3 on Ubuntu 14.04
Install oracle java8 on amazon linux2
Install and run dropbox on Ubuntu 20.04
Install OpenCV and Chainer on Ubuntu
Install CUDA 8.0 and Chainer on Ubuntu 16.04
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Install CUDA on Linux Mint Mate 20
Install Arch Linux on DeskMini A300
Install Pytorch on Blender 2.90 python on Windows
How to install VMware-Tools on Linux
How to install pycrypto on Windows
Integrate Modelica and Python on Windows
Install pyenv on EC2 (Amazon Linux)