Skip to content

WSL

WSL 是 Microsoft 公司在 2016 年发布的,旨在允许开发者在 Windows 操作系统上直接运行 Linux 二进制可执行文件。它通过一个兼容层实现了这一功能,无需进行虚拟机设置。

FAQs

修复属主 Windows 的目录和文件权限

创建或更新 /etc/wsl.conf

ini
[boot]
systemd=true

[user]
default=<your-windows-user-name>

[automount]
options = "metadata,umask=22,fmask=11"

PowerShell wsl --shutdown 然后重启虚拟机即可生效。

WSL ubuntu 中访问 host 的所有文件目录都很慢

git status .

Option a: 把项目从 /mnt/c/... 迁移到 WSL 本地

shell
cp -r /mnt/c/Users/<username>/projects/your-repo ~/projects/your-repo
cd ~/projects/your-repo
git status

Option b: 调优 WSL2 的 9P 缓存

%USERPROFILE%\.wslconfig 中加:

ini
ini[wsl2]
# 给更多内存(减少 swap)
memory=8GB

[experimental]
# 启用更快的 9P 实现(WSL 2.0.0+ 支持)
sparseVhd=true
autoMemoryReclaim=gradual

Released under the CC-BY-NC-4.0