WSL/UBUNTU:在 Windows 中,使用 GNU Linux 工具的方法;
该笔记将记录:在 Windows 中,如何使用 WSL 模块,以及相关问题的解决方法;
解决方案
# 09/13/2021
我们需要在笔记本中运行 VirtualBox 5.2 版本,但是 VirtualBox 与 Hyper-V 不能共存:
1)如果开启 Hyper-V 模块,那么 VirtualBox 将提示 VT-x is not available 错误;
2)如果关闭 Hyper-V 模块,那么 WLS 2 将提示 The specified network name is no longer available 错误;
鉴于 VirtualBox 能够将主机文件系统挂在到虚拟机中,所以能够在 Linux 环境下进行操作。这能够满足我们的需求,所以我们放弃使用 WSL 2 特性;
认识
What is the Windows Subsystem for Linux?
https://learn.microsoft.com/en-us/windows/wsl/about
Comparing WSL 1 and WSL 2
https://learn.microsoft.com/en-us/windows/wsl/compare-versions#comparing-wsl-1-and-wsl-2
WSL, VirtualBox and VMware
WSL 2 will work with VMware 15.5.5+ and although VirtualBox 6+ states that there is WSL support, there are still significant challenges that make it unsupported. Learn more in our FAQs.
构建
环境部署 | Setting Up Environment
通过命令安装
补充说明:针对通过命令行安装的方式,其需要访问 github 站点,所以需要处理网络相关的问题。
通过手动安装(废弃)
参考 Windows Subsystem for Linux Installation Guide for Windows 10 文档;
# 02/18/2024 通过手动安装会遇到较多问题,且过程相较繁琐,所以我们不再使用该方式。
安装步骤
1)Control Panel ⇒ Programs ⇒ Turn Windows features on or off
2)启用 Windows Subsystem for Linux 选项,并重启主机;
3)在 Microsoft Store 中,搜索并安装 Ubuntu 20.04 TLS 发行版;
在安装完成后,Windows Terminal 能够快速进入 Ubuntu 20.04 中(如果需要设置,参考 Install and set up Windows Terminal 文档)
常见问题
WSL2 wslregisterdistribution failed with error: 0x8004032d · Issue #10508 · microsoft/WSL
// -------------------------------------------------------- // WslRegisterDistribution failed with error: 0x800701bc Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x800701bc Error: 0x800701bc WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel Press any key to continue... // -------------------------------------------------------- // WslRegisterDistribution failed with error: 0x8004032d Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x8004032d Error: 0x8004032d (null) Press any key to continue... // dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
改进
常见问题处理
The specified network name is no longer available.(指定的网络名不再可用)
原因分析,正如 Microsoft 官方 FAQ 所说:
解决方案,我们需要开启 Hyper-V 组件,但为了 VirtualBox 能够正常运行,需要升级 VirtualBox 至 6.0.0 版本(VirtualBox 不支持以多版本运行),因为在 alBox 6.0.0 中 Added support for using Hyper-V as the fallback execution core on Windows host, to avoid inability to run VMs at the price of reduced performance