✅ This is a tutorial of installing on WSL2
Install WSL2
Start using WSL
Open powershell
using administration rights, and input:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart |
Requirement of WSL2
For x64 system, the version of win10 must be 1903 or higher.
Using “win + R” and input winver
to check.
Start Virtual machinel platform
Open powershell
using administration rights, and input:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart |
Install Linux Kernal Updating
Download Link: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Install.
Setting the default version 2
Open powershell
using administration rights, and input:
wsl --set-default-version 2 |
Then, WSL2 is already installed.
Update to WSLg
将win10更新到最新的版本
Open powershell
using administration rights, and input:
wsl --update |
否则说明win10还不是最新的,继续更新
Install Archlinux on WSL2
Download Archlinux
Download link: https://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/latest/
Find and Download archlinux-bootstrap-2020.10.01-x86_64.tar.gz
.
Install Archlinux by LxRunOffline
1. Input the command in powershell
LxRunOffline i -n <自定义名称> -f <Arch镜像位置> -d <安装系统的位置> -r root.x86_64 |
example:
LxRunOffline i -n ArchLinux -f C:\Users\dionysen\Downloads\archlinux-bootstrap-2020.10.01-x86_64.tar.gz -d C:\Users\dionysen\Linux -r root.x86_64 |
2. Change WSL2 version in Archlinux
wsl --set-version ArchLinux 2 |
Configuration
Basic Configuration
wsl -d Archlinux |
The terminal window will be unavailable, so you should reopen a new terminal window, then:
wsl --shutdown Archlinux |
Add following code in the end of pacman.conf
:
[archlinuxcn] |
And change the mirrorlist:
vi ./pacman.d/mirrorlist |
Remove the comment of a Chinese source.
pacman -Syy |
Use /wheel
find the line wheel ALL=(ALL) ALL
and remove the comment.
id -u <username> |
Execute the command in powershell
to set default user of Archlinux:
lxrunoffline su -n Archlinux -v <username> |
Install Ubuntu20.02 in WSL2
wsl --list --online # 查看可直接安装的发行版列表 |
然后打开终端,打开ubuntu-20.04,创建用户和密码
换源+更新
然后安装anaconda
Install Anaconda on Ubuntu
wget https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-5.3.0-Linux-x86_64.sh |
安装完成之后,检查版本:
anaconda -V |
使用anaconda
换源:
cd |
编辑.condarc
,添加清华源
# add to .condarc |
更新:
conda update -n base -c defaults conda # 升级anaconda |
conda create -n myconda python=3.7 # 创建虚拟环境,名称为myconda(可以修改 |
conda list # 查看conda的包 |
附加配置
systemd
编辑 /etc/wsl.conf
[boot] |
WSL distros 的备份还原
- 备份
wsl -l -v |
- 还原
wsl --import <distro-name> <install-path> <backup-file> |
WSL-Ubuntu安装 [[Computer/Programming/Language/Qt|qt]]
sudo apt install qt5* qtcreator |
创建项目时如果出现“no suitable kits”,点击“option”查看配置,如果“QT version”为“none”,则选择 /usr/lib/qt5/bin/qmake
,保存即可。
- Post title: WSL2
- Create time: 2023-05-25 17:34:01
- Post link: 2023/05/25/note/Wiki/WSL2/
- Copyright notice: All articles in this blog are licensed under BY-NC-SA unless stating additionally.