win上手动安装WSL体验Linux

734 阅读1分钟

背景

由于公司网络限制,Microsoft Store上下载Ubuntu总提示下载失败,所以只能手动下载了

手动安装wsl

官网安装教程

1.启用适用于Linux 的 Windows 子系统

管理员权限在powershell里面运行

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

2.检查运行 WSL 2 的要求

要更新到 WSL 2,您必须运行 Windows 10 或 Windows 11。

3.启用虚拟机功能

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

4.将 WSL 2 设置为默认版本

wsl --set-default-version 2

5.下载发行版

由于公司有网络限制,我是手动下载的appx包,可选以下的其一

下载发行版后,导航到包含下载内容的文件夹并在该目录中运行以下命令,其中app-name是 Linux 发行版 .appx 文件的名称。

Add-AppxPackage .\Ubuntu-20.04.appx

遇到问题

在打开Ubuntu 的时候,报错“WslRegisterDistribution failed with error: 0x800701bc”

解决方案

下载适用于x64计算机的 WSL2 Linux 内核更新包:wslstorestorage.blob.core.windows.net/wslblob/wsl…

image.png

开始体验

image.png

/mnt

添加/mnt前缀,可访问win下的文件系统 image.png