.vhdx 文件的磁盘路径
把distribution-name替换成通过wsl -l -v看到的发行版的名称
1 2 3 4 5 6
| wsl -l -v
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '<distribution-name>' }).GetValue("BasePath") + "\ext4.vhdx"
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq 'archlinux' }).GetValue("BasePath") + "\ext4.vhdx"
|
压缩磁盘
压缩前先关闭wsl
然后输入diskpart
此时弹出一个新的命令行窗口,依次输入下面内容,其中file的值替换成上面一步得到的路径
1 2 3 4 5 6 7 8 9 10
| select vdisk file="/path/to/your/.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
|
参考