当前位置:网站首页>WSL 2 will not be installed yet? It's enough to read this article
WSL 2 will not be installed yet? It's enough to read this article
2022-07-02 12:06:00 【raelum】
Catalog
One 、 Prerequisite
about 64 Bit system , If you want to install WSL 2, Need to meet OS Internal version ≥18362.
Press down win + R , Then input winver Check it out. OS Build of :

It can be seen that our version number meets the requirements , So you can install .
Two 、 Enable for Linux Of Windows Subsystem
With Administrator status open Powershell, Then enter the following command :
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
After the execution Don't turn it off yet window .
3、 ... and 、 Enable virtual machine
continue stay Powershell Type the command in the window :
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Close the window after execution , restart Computer .
Four 、 to update Linux kernel
First download Apply to x64 The computer WSL 2 Linux Kernel update package , Then double click to install .
If you are prompted to provide elevated permissions , choice “ yes ” To approve this installation .
5、 ... and 、 take WSL 2 Set as default version
With Administrators Identity open Powershell, Then enter the following command :
wsl --set-default-version 2
6、 ... and 、 install Linux Distribution version ——Ubuntu
in fact Microsoft Store You can complete the installation in , But here we choose to install it manually , Because the manual installation has strong controllability .
some Linux Distribution and its download address :
| Linux Distribution version | Download |
|---|---|
| Ubuntu | https://aka.ms/wslubuntu |
| Ubuntu 20.04 | https://aka.ms/wslubuntu2004 |
| Ubuntu 18.04 | https://aka.ms/wsl-ubuntu-1804 |
| Debian GNU/Linux | https://aka.ms/wsl-debian-gnulinux |
| Kali Linux | https://aka.ms/wsl-kali-linux-new |
| Fedora Remix for WSL | https://github.com/WhitewaterFoundry/WSLFedoraRemix/releases/ |
Here we have Ubuntu 20.04 For example , When the download is complete , You'll get one called CanonicalGroupLimited.UbuntuonWindows_2004.2021.825.0.AppxBundle The file of . As can be seen from the suffix , It is associated with the Microsoft Store .
WSL 2 The essence of is virtual machine , The relevant files will be stored in the virtual disk ( Suffix named .vhdx), The disk initially has more than one G, If installed later docker Wait for the software C The dish is unbearable , So we need to install it in other disks ( for example D disc ).
Double click to download the good AppxBundle File to install , It will be installed by default to C disc . Here's the picture , Click Install directly :

After installation , A pop-up window will pop up for us to set the user name and password ( Note that the password will not echo ), Close the window after setting .
The next step is to migrate , We use Administrators Identity open Powershell window , Then input
wsl -l --all -v
To view the installed distributions .

Note that the name of our distribution is Ubuntu instead of Ubuntu-20.04.
Suppose we want to move to D disc , First, release the version as .tar The format is exported to D disc :
wsl --export Ubuntu d:\wsl-ubuntu.tar
Then log out of the current release :
wsl --unregister Ubuntu
Then re import and install WSL 2 stay D:\Ubuntu Next :
wsl --import Ubuntu d:\Ubuntu d:\wsl-ubuntu.tar --version 2
Besides , You also need to set the user name of the default login user to the original user name :
ubuntu config --default-user raelum
Finally delete .tar file
del d:\wsl-ubuntu.tar
7、 ... and 、 install Windows Terminal
stay Microsoft Store Search inside Windows Terminal And install :

7.1 take Ubuntu The default running environment is ( Optional )
take Ubuntu Setting as the default running environment means , When we start Windows Terminal Or click “+” No. when creating a new window , A new one will be created automatically Ubuntu The window of :

Set by , First click the inverted triangle , Select settings from the pop-up drop-down list :

Click the gear button again in the pop-up window to open settings.json file :

We are profiles Of list Find below Ubuntu Corresponding guid :

then defaultProfile hinder guid Replace with this guid that will do :

7.2 Set the startup directory to user HOME Catalog
WSL 2 The default startup directory is Windows User root :C:\Users\<Username>, instead of Linux User's in the system HOME Catalog , So we need to be able to settings.json Make a change in .
in fact , Only need profiles Of list Find below Ubuntu, Then add a line :
"startingDirectory": "//wsl$/<Ubuntu_name>/home/<username>"
that will do , among <Ubuntu_name> Is your Ubuntu The name of the distribution , The last save settings.json Even if the setting is completed .
边栏推荐
- HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
- Leetcode122 the best time to buy and sell stocks II
- 机械臂速成小指南(七):机械臂位姿的描述方法
- Time format display
- QT meter custom control
- [QT] Qt development environment installation (QT version 5.14.2 | QT download | QT installation)
- Some problems encountered in introducing lvgl into esp32 Arduino
- Yygh-9-make an appointment to place an order
- 二分刷题记录(洛谷题单)区间的甄别
- jenkins 凭证管理
猜你喜欢

PyTorch nn.RNN 参数全解析

基于Arduino和ESP8266的Blink代码运行成功(包含错误分析)

Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)

HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE

ESP32 Arduino 引入LVGL 碰到的一些问题

自然语言处理系列(一)——RNN基础

Develop scalable contracts based on hardhat and openzeppelin (I)

YYGH-BUG-05

【工控老马】西门子PLC Siemens PLC TCP协议详解

jenkins 凭证管理
随机推荐
Map和Set
还不会安装WSL 2?看这一篇文章就够了
From scratch, develop a web office suite (3): mouse events
Depth filter of SvO2 series
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
Natural language processing series (I) -- RNN Foundation
多文件程序X32dbg动态调试
php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
YYGH-BUG-05
FastDateFormat为什么线程安全
(C语言)输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
HOW TO ADD P-VALUES TO GGPLOT FACETS
H5,为页面添加遮罩层,实现类似于点击右上角在浏览器中打开
ESP32 Arduino 引入LVGL 碰到的一些问题
动态内存(进阶四)
[visual studio 2019] create and import cmake project
Natural language processing series (III) -- LSTM
HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE
【C语言】杨辉三角,自定义三角的行数
b格高且好看的代码片段分享图片生成