WSL2 (Preview) Experience notes

WSL2 installation

WSL2 be released in May this year, Microsoft Build conference, but so far has not received updates Windows10 push, I think for so long in the past even if not formally enter, at least to the RC version of it, and began to toss ready to experience one.

WSL2 need more support Windows10 version of the 18917 or, as of 2019-08-22, this version is still in the internal preview of the state, if necessary, have to set up the system of "Windows Experience Program Preview" to make the appropriate changes, join the preview experience Program, and then you can receive updated content preview version of the Windows. - specific process slightly, with particular attention to is this update process is relatively long, to find free time to do it.

Open these two functions in the "Enable Windows features on or off" in

  1. Linux implementation of the program of the Windows subsystem (this is a WSL)
  2. Virtual Machine platform (WSL2 need this, WSL1 is not needed, remember to open the BIOS settings in the CPU virtualization technology)

Or as an administrator to run Powershell, and then execute:

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

Installing Ubuntu in Windows10 applications store, or Ubuntu 18.04 LTS, or other distributions will do (I'm not familiar with CentOS ye do?). Then click on the Start menu, run, run for the first time will be very slow, because there is the installation process, be patient, you are prompted to enter a user name and password is completed, the Windows user name and password is irrelevant.

WSL2 use

Open a command line interface (cmd.exe), now to become familiar with several WSL2 configuration commands:

>wsl -l --verbose

This command will list the Linux distribution currently installed name, status and version of WSL, such as:

NAME         STATE      VERSION
*Ubuntu      Running    1
Ubuntu-18.04 Running    2

* Indicates default previous releases wsl, and this can be seen WSL Ubuntu use for the first edition, to use Ubuntu into WSL2 can use this command:

>wsl --set-version Ubuntu 2

Set in a future release are installed using WSL2

>wsl --set-default-version 2

Another wslconfig command can also control the release operation, specific direct knock this command will be able to see the help information.

A big difference WSL2 and WSL is to use a virtual disk is not directly present in the Windows file system like WSL file as the default WSL disk storage in place:

%localappdata%\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState

There is a large file named vhdx extension of this directory, which is the virtual disk image files.

Before the WSL, to access Windows in Linux is some problem, though using the same file system, but directly to the file directory Linux's throw papers seem useless, probably related with the refresh, and are not recommended, and now convenient, knocking at WSL in explorer.exe. , WSL can open the current directory with Windows Explorer, note that this function can only be performed in WSL's window, if it is SSH terminal, it will be prompted to find explorer.exe less than command.

pit

After you deploy WSL, I find VMWare Workstation Pro can no longer use, suggesting that "VMware Workstation and Device / Credential Guard incompatible", search solution, closed the issue after "Device / Credential Guard" in the Windows Group Policy remains. Through access to information, understand WSL2 architecture undergone major changes, it uses some virtualization technology (but not exactly the same VM, VM much faster rate than it started, so I have a more specific understanding before making a share), it is not difficult to understand why WSL need to have to open a "virtual platform" may use this feature, WSL2 therefore support the Docker, which shows that it is already a pure Linux, and Windows, however, virtualization with VMWare virtualization technology used is very different, incompatible with each other, if you've used before Hyper-V, then we must know this matter. Now how to do it? My solution is to give up VMWare, VMWare disk image of the original document into Hyper-V disk image format, using Hyper-V virtual machine ...... uh, actually not the solution, VMWare cool, with a who's who I know, so I think this is one of the largest WSL2 pit.

This raises a question: WSL2 also called WSL it? I think it is closer to a run in the Windows environment after a special optimized Linux virtual machine, instead of a Subsystem.

Today WSL2 can be seen as a separate virtual machine (though technically still some differences), it has its own independent IP address, through a virtual router with Windows, although you deploy in WSL2 service in Windows can with localhost access, but I guess this is some special internal link technology to achieve, I do not believe you can do such a simple test: If you deploy in WSL2 and running redis, if the configuration file only bind to 127.0 .0.1 words, Windows is not the localhost or 127.0.0.1 to access WSL2 redis services available. To see WSL2 ip address, ip addr command can be used in WSL2 or ifconfig command. In addition, I also found that in use with this localhost address inaccessible WSL2 the ssh service, I tried turning off Windows Firewall, checked the port is open and the bound state with netstat, are not the problem, and as long as the localhost into the WSL2 IP address (usually 172.xxx) can, at the same time, access to services and redis PostgreSQL service WSL2 use localhost addresses are not the problem, I feel very strange.

There are noteworthy point is: IP address WSL2 is dynamic, after each start will be different, so I do not directly specify the IP address of a good way to access WSL2 the ssh service.

I also found the WSL1 not start automatically sshd and other issues still exist today, although I can be resolved by means of some small, some people online gives some workaround, but I fear that is not enough neat.

to sum up

In fact, now everything is not the final release, if energy is limited, I think it is good that the first not into the pit, so I toss down, feeling not worth ......

Guess you like

Origin www.cnblogs.com/guogangj/p/11403259.html