WSL2 (Windows Subsystem for Linux) installation procedure

WSL2 (Windows Subsystem for Linux) installation procedure

Windows update procedure

According to the Official page, it seems that the following version or later is required.

WSL 2 is only available on Windows 10, version 2004, build 19041 and above. You may need to update your version of Windows.

For the time being, I checked my Window version.

WindowsUpdate.png

winver1903.png

On the Windows Update screen, "It is up to date" is displayed, but for some reason the version is not enough. We updated the version of Windows from the following page.

Download Windows 10

When the version update is completed, the following will be displayed.

winver2004.png

WSL2 (Windows Subsystem for Linux) installation procedure

With reference to Official procedure page, we proceeded with the following introduction.

Enable "Windows Subsystem for Linux" optional feature

The "Windows Subsystem for Linux" optional feature must be enabled before installing a Linux distribution on Windows. Open PowerShell as an administrator and do the following:

PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Deployment image services and management tools
version: 10.0.18362.900

Image version: 10.0.18362.1016

The function is enabled
[==========================100.0%==========================]
The operation completed successfully.

Enable optional components of "Virtual Machine Platform"

The "Virtual Machine Platform" optional feature must be enabled before installing WSL 2. Open PowerShell as an administrator and do the following:

PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Deployment image services and management tools
version: 10.0.18362.900

Image version: 10.0.18362.1016

The function is enabled
[==========================100.0%==========================]
The operation completed successfully.

Reboot your machine to complete the WSL installation and update to WSL 2.

Set WSL2 as the default version

As an administrator, open PowerShell and run the following command to set WSL 2 as the default version when installing a new Linux distribution.

PS C:\WINDOWS\system32> wsl --set-default-version 2
error: 0x1bc
For the main differences from WSL 2, https://aka.ms/See wsl2

A "0x1bc" error was output. Since there was officially the following description, I thought it was another error, but I tried updating the kernel. Kernel update download link

This message may appear after running the command WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel. Follow the link (https://aka.ms/wsl2kernel) to install the MSI from this page of the documentation for installing the Linux kernel used by WSL 2 on your computer. After installing the kernel, run the command again and it completes successfully without any message.

After updating the kernel, when I ran it again, no error was output.

PS C:\WINDOWS\system32> wsl --set-default-version 2
For the main differences from WSL 2, https://aka.ms/See wsl2

Install a Linux distribution

Open the Microsoft Store and select your preferred Linux distribution.

This time, "Ubuntu 20.04 LTS" was introduced.

MicrosoftStore_Ubuntu.png

After completing the above installation, you will be asked to wait a few minutes the first time you start Ubuntu. After that, you will be asked to set the Ubuntu user and password as shown below, so set them.

ubuntuinstall.png

Set the version of WSL used by the distribution

When I checked the WSL version assigned to the installed Ubuntu, version 1 was assigned.

PS C:\WINDOWS\system32> wsl --list --verbose
  NAME      STATE           VERSION
* Ubuntu    Stopped         1

To assign version 2, use the following command.

PS C:\WINDOWS\system32> wsl --set-version Ubuntu 2
Converting. This process can take a few minutes...
For the main differences from WSL 2, https://aka.ms/See wsl2
The requested operation could not be completed due to a virtual disk system limitation. The virtual hard disk file must be decompressed and encrypted. Also, virtual hard disk files cannot be set to sparse.

An error was displayed saying "The requested operation could not be completed due to a virtual disk system limitation." Since it is recommended to decompress and decrypt the file, the following was performed.

If you go to% localappdata% \ Packages from the URL bar, you can find the Ubuntu distribution entity with a folder name like "CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc". Uncheck Properties> Advanced> Compress Contents to Save Disk Space.

After performing the above, I tried again.

PS C:\WINDOWS\system32> wsl --set-version Ubuntu 2
Converting. This process can take a few minutes...
For the main differences from WSL 2, https://aka.ms/See wsl2
The conversion is complete.

It seems that the setting is completed, so when I check the WSL version assigned to Ubuntu again, the version is updated to 2.

PS C:\WINDOWS\system32> wsl --list --verbose
  NAME      STATE           VERSION
* Ubuntu    Stopped         2

This completes the settings!

Recommended Posts

WSL2 (Windows Subsystem for Linux) installation procedure
When Windows Subsystem for Linux (WSL) cannot be started
Teamviewer for Linux installation procedure (CentOS)
pykintone on Windows Subsystem for Linux
How to set up Ubuntu for Windows Subsystem for Linux 2 (WSL2)
Windows Subsystem for Linux is not displayed
How to install Windows Subsystem For Linux
Until Windows Subsystem for Linux (WSL) is installed in Windows and fish is installed
Linux mint installation procedure
Linux (WSL) on Windows
Offline installation procedure for openpyxl
Installation notes for TensorFlow for Windows
Use Linux on Windows 10 (WSL2)
Comfortable LaTeX with Windows Subsystem for Linux and VS Code
JupyterLab3.0 Debugger Installation Method for Windows
[Go] Procedure for installing Go on WSL2
About the procedure for linking Visual Studio Code for Windows and WSL
Python project environment construction procedure (for windows)
Install wsl2 and master linux on windows
Pylearn 2 installation procedure
Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)
Python installation (Windows)
From ROS for Windows installation to operation check
pyenv for linux
Organize files on Windows with Linux commands-using WSL-
PostgreSQL 10.0 installation procedure
blockdiag installation procedure
When I tried to use Python on WSL (windows subsystem for linux), it got stuck in Jupyter (solved)
[Linux] WSL2 Build an environment for laravel7 with Ubuntu 20.04
Procedure for building a CDK environment on Windows (Python)
I wrote an automatic installation script for Arch Linux
Cross development environment (developing programs for windows on linux)
AWS CLI installation procedure
LibYAML installation (Linux / Unix)
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
django-debug-toolbar installation procedure memo
Python installation method Windows
[For memo] Linux Part 2
[Linux] Installation of nvm
Linux, Windows proxy settings
ubuntu20.04 + Geth installation procedure
What is Linux for?
Linux command for self-collection
Seurat in Linux (installation)
Anaconda3 environment installation procedure
Scrapy environment installation procedure
Arch Linux installation notes
Install Python (for Windows)
Installation procedure for Python and Ansible with a specific version
[PowerShell] How to search for rows like Linux grep (Windows)