Blame

40f8bf Qwas 2024-03-31 13:59:57 1
# WSL使用
2
3
## wsl 命令行
4
5
选择安装 Linux 发行版
6
7
```sh
8
wsl --install
9
```
10
11
```sh
12
wsl --install -d Ubuntu
13
```
14
15
![wsl--install](https://static.qwas.fun/notes/2024/01/wsl--install.png)
16
17
`wsl --status`查看 wsl 程序版本
18
19
`wsl --update` 更新 wsl 程序
20
21
![wsl--status && wsl--update](https://static.qwas.fun/notes/2024/01/wsl--status-wsl--update.png)
22
23
`wsl --version` 查看 wsl 版本信息,较新版本 wsl 可用,旧版本没有这个命令参数
24
25
![wsl--version](https://static.qwas.fun/notes/2024/01/wsl--version.png)
26
27
28
`wsl --set-version 虚拟机名称 wsl版本号` 为虚拟机指定 WSL 版本
29
30
`wsl --set-version Ubuntu 2`
31
32
参看文档:[比较 WSL 版本 | Microsoft Learn](https://learn.microsoft.com/zh-cn/windows/wsl/compare-versions)
33
34
![wsl--version](https://static.qwas.fun/notes/2024/01/wsl--set-version.png)
35
36
## 磁盘管理
37
38
WSL 虚拟硬盘 (VHD) 的大小会随着使用而增加,设置稀疏磁盘后,系统会自动回收磁盘空间。
39
40
```sh
41
wsl --manage Ubuntu --set-sparse true
42
```
43
44
[有没有人用 wsl2 开发啊?文件系统爆炸磁盘待解救。 - V2EX](https://www.v2ex.com/t/996219)
45
46
```sh
47
diskpart
48
select vdisk file="xxxx.vhdx"
49
compact vdisk
50
detach vdisk
51
```
52
53
Ubuntu 默认版本磁盘路径为
54
55
```text
56
C:\Users\dong\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx
57
```
58
59
## 安装 zsh
60
61
```sh
add8b1 Qwas 2024-05-02 01:47:04 62
sudo apt install zsh
40f8bf Qwas 2024-03-31 13:59:57 63
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
64
```