admin管理员组文章数量:1655036
通过软连接的方式修改VHDX 文件的存放磁盘,达到缓解C盘存储压力的问题
软连接方式
$newLocation = "E:\WSL\Ubuntu-WSL2\"
cd ~\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState
wsl --shutdown
Optimize-VHD .\ext4.vhdx -Mode Full
mkdir $newLocation -Force
mv ext4.vhdx $newLocation
cd ..
rm LocalState
New-Item -ItemType SymbolicLink -Path "LocalState" -Target $newLocation
导出导入方式
关闭wsl
wsl --shutdown
查看系统信息 wsl -l -v
> wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
导出系统 wsl --export <DistroName> <PathToTarArchive>
wsl --export Ubuntu-20.04 E:\WSL\Ubuntu20.04-WSL2\ubuntu.tar
删除系统 wsl --unregister <DistroName>
wsl --unregister Ubuntu-20.04
导入系统 指定新的位置 wsl --import <DistroName> <PathToDistroNewDirectory> <PathToTarArchive>
wsl --import Ubuntu-20.04 E:\WSL\Ubuntu-WSL2 E:\WSL\Ubuntu20.04-WSL2\ubuntu.tar
wsl -l -v
设置默认用户
ubuntu2004.exe config --default-user xxx
参考
https://murrahjm.github.io/Exporting-WSL-data/
https://dev.to/milolav/manually-installing-wsl2-distributions-41b4
https://github/microsoft/WSL/issues/4699#issuecomment-660104214
本文标签: 磁盘
版权声明:本文标题:windows10修改wsl2的存储磁盘 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729690597a1210124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论