当前位置:网站首页>[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx
[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx
2022-06-13 01:25:00 【Ryan ZHENG】
WSL2本质上是一个虚拟机,因此必然存在磁盘镜像文件。
默认情况下,这个镜像文件会放在C盘(参考官网举例:%LOCALAPPDATA%\Packages<PackageFamilyName>\LocalState<disk>.vhdx)
但是由于部分厂商预装系统时,C盘并不会流出较大容量,这就会导致C盘可用空间随着WSL2的使用逐渐耗尽;
为了将这个磁盘镜像文件移动到其他分区(下方以D盘为例),故写下这篇文章;
这篇比较简单,权当一个笔记,记录下步骤:
- 打开带管理员权限的PowerShell

- 首先输入wsl -l -v查看当前已经安装的WSL实例:
PS C:\windows\system32> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
如图,我只安装了一个WSL2的实例,名为Ubuntu
3. 接下来需要将现有WSL2实例备份导出:
wsl --export Ubuntu D:\Ubuntu_bak.tar
这里以导出到D盘下,命名为Ubuntu_bak.tar为例
- 备份完成后可以注销现有实例了:
wsl --unregister Ubuntu
- 然后从Ubuntu_bak.tar导入,此时可以指定存放虚拟磁盘镜像文件的路径了:
wsl --import Ubuntu_new D:\WSL_Ubuntu D:\Ubuntu_bak.tar --version 2
参数解读:
- Ubuntu_new
· 实例名称,可以自己设置,设置后即为第2步输入wsl -l -v后显示的名称; - D:\WSL_Ubuntu
· 导入后的镜像及其相关数据存放路径; - D:\Ubuntu_bak.tar
· 导入的备份,即第3步通过wsl --export导出的文件; - –version 2
· WSL版本为2
- 设置默认登录用户
ubuntu config --default-user ryan
- ubuntu是你在微软商店安装的Linux分发版的名称,如果你安装的是Ubuntu20.04,这里就执行ubuntu2004,以此类推;
- 完成

边栏推荐
- [从零开始学习FPGA编程-22]:进阶篇 - 架构 - FPGA内部硬件电路的设计与建模
- Leetcode question brushing 06 bit operation
- np. Understanding of axis in concatenate
- Most elements leetcode
- How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of DBCD, ROC, vroc, Cr and psy index strategy income
- Alexnet实现Caltech101数据集图像分类(pytorch实现)
- leetcode. 151. flip the words in the string
- Page optimization - Notes
- FSOs forest simulation optimization model learning notes
- Tkinter library installation
猜你喜欢
随机推荐
Wikipedia API User Guide
September 3, 2021 visual notes
Argparse command line passes list type parameter
Crypto JS reports uglifyjs error
A summary of global variables and typedef
leetode. 242. valid Letter heteronyms
Leetcode-17- letter combination of phone number (medium)
pycharm add configutions
The tle4253gs is a monolithic integrated low dropout tracking regulator in a small pg-dso-8 package.
Method of cleaning C disk
redis
Polymorphism and virtual function
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators
Logical operation bit operation
leetcode. 541. reverse string II
Leetcode 01 array
MySQL related summary
Leetcode-14- longest common prefix (simple)
Reinstall opencv and step on the pit.
Sonarqube local installation









