WSL2 is an abbreviation of "Windows Subsystem for Linux2", which runs Linux on Windows. Since Linux (WSL2) was very easy, I summarized the installation procedure.
Basically, I introduced WSL2 by the procedure of Microsoft. At that time, there was a terminal that caused an error when installing the Linux distribution (Ubuntu-20.04), so write down the workaround.
--Distribution to be introduced Ubuntu-20.04 (introduced from Windows Store)
--Host to be installed (an error occurred) --Windows10 Pro 64bit 1909 (OS build 18363,1198) --Result of uname -r: 4.19.128-microsoft-standard - CPU:Core-i7 5500U --Program: Windows Subsystem for Linux Update 4.19.128 --Winodws10 Pro 20H2 (OS build 19042,630)
--Host to be installed (No error occurred here) --Windows10 Pro 64bit 1909 (OS build 18363,1198) --Result of uname -r: 4.19.128-microsoft-standard - CPU:Core-i7-7500U --Program: Windows Subsystem for Linux Update 4.19.128 - KB4023057
I didn't clearly understand the environmental difference that led to the error, but I feel that it was caused by antivirus software. It is posted for your reference.
--Linux is available on Windows. --Easy to link with Windows. --WSL2 runs on a lightweight virtual machine and has high system call compatibility. - https://docs.microsoft.com/ja-jp/windows/wsl/about - https://www.atmarkit.co.jp/ait/articles/1906/14/news019.html
Start the prompt with administrator privileges.
powershell start-process cmd -verb runas
For x64 systems: version 1903 and above, build 18362 and above. For ARM64 systems: Version 2004 and above, build 19041 and above. Builds prior to 18362 do not support WSL 2. And that.
Run "winver" at the prompt to see the version and build number. You can also run "winver" by pressing the Windows logo key + R key.
winver
C:\>dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Deployment image services and management tools
version: 10.0.18362.1139
Image version: 10.0.18363.1198
The function is enabled
[==========================100.0%==========================]
The operation completed successfully.
C:\>dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Deployment image services and management tools
version: 10.0.18362.1139
Image version: 10.0.18363.1198
The function is enabled
[==========================100.0%==========================]
The operation completed successfully.
Restart.
C:\>shutdown /r /t 0
--Download below. - https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi --Run and install.
wsl --set-default-version 2
For the main differences from WSL 2, https://aka.ms/See wsl2
Press the Ubuntu 20.04 TLS launch button in the Windows Store.
Hopefully you'll be asked for a username and you'll be prompted for Linux. ** In my case, I ran into the following error: ** **
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 ???????????????????????????????????
Press any key to continue...
Below are two ways to avoid the error.
Introducing two methods.
This workaround is a method posted in the Microsoft Community. https://answers.microsoft.com/en-us/insider/forum/all/wsl-2-installing-linux-failed-error-code/bae391d1-4215-4d93-b0c4-3d96404a7c74?auth=1
** Turn off Override System Settings **
net start vmcompute
(The procedure does not tell you to restart, but just in case)
C:\>shutdown /r /t 0
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: dev
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
dev@pc:~$
If you install in WSL1 mode, you do not need to change vmcompute.
C:\> wsl --set-default-version 1
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.4.0-18362-Microsoft x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Fri Nov 27 12:15:55 JST 2020
System load: 0.52 Users logged in: 0
Usage of /home: unknown IPv4 address for eth0: 172.16.91.38
Memory usage: 41% IPv4 address for eth2: 172.18.78.193
Swap usage: 0% IPv4 address for eth3: 172.17.234.113
Processes: 7
1 update can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
This message is shown once once a day. To disable it please create the
/home/dev/.hushlogin file.
Check the installed distribution with the WSL command. (Check from Windows command prompt)
C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Stopped 1
Did you install it with the above?
C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
C:\> wsl -d Ubuntu-20.04
dev@pc:/$ ps
PID TTY TIME CMD
262 pts/2 00:00:00 bash
275 pts/2 00:00:00 ps
dev@pc:/$ uname -r
4.19.128-microsoft-standard
dev@pc:/$ cat /etc/issue
Ubuntu 20.04.1 LTS \n \l
The C drive is mounted at/mnt.
C:\> wsl -d Ubuntu-20.04
dev@pc:/$ cd /mnt
dev@pc:/$ ls -l
total 4
drwxrwxrwx 1 dev dev 4096 Dec 10 08:15 c
drwxrwxrwx 1 dev dev 4096 Dec 10 08:14 d
drwxrwxrwx 2 root root 4096 Nov 25 22:24 m
drwxrwxrwt 5 root root 100 Dec 12 21:16 wsl
An example of creating WSL2 after creating it with WSL1.
C:\> wsl --set-version Ubuntu-20.04 2
wsl --export
C:\> wsl --export Ubuntu-20.04 c:\work\Ubuntu-20.04.tar
wsl --import
C:\> wsl --import MyUbuntu-20.04-dev c:\work\MyUbuntu-20.04-dev c:\work\Ubuntu-20.04.tar
C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
MyUbuntu-20.04-dev Stopped 2
C:\> dir /B c:\work\MyUbuntu-20.04-dev
ext4.vhdx
C:\> wsl --unregister <Distribution>
Start Powershell with administrator privileges.
powershell start-process powershell -verb runas
Execute the command to check the validity of WSL.
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Execution result
FeatureName : Microsoft-Windows-Subsystem-Linux
DisplayName :Windows subsystem for Linux
Description :Provides services and environments for running native user-mode Linux shells and tools on Windows
I will serve you.
RestartRequired : Possible
State : Enabled
CustomProperties :
ServerComponent\Description :Linux shells and tools in native user mode on Windows
It provides the services and environment to do it.
ServerComponent\DisplayName :Windows subsystem for Linux
ServerComponent\Id : 1033
ServerComponent\Type : Feature
ServerComponent\UniqueName : Microsoft-Windows-Subsystem-Linux
ServerComponent\Deploys\Update\Name : Microsoft-Windows-Subsystem-Linux
Reference: https://docs.microsoft.com/ja-jp/windows/wsl/troubleshooting
I think you can use Linux on Windows quite easily. When installing Docker Desktop, please install it with WSL2 instead of WSL1. The number of distributions available in the Windows Store is limited, but we expect more.
--WSL document
--Introduction of WSL
--Comparison of WSL1 and WSL2. VHD (Disk Space) expansion with WSL2.
--WLS support on Windows 10-1903
Recommended Posts