wsl镜像转换存储位置

0.缘起

wsl的linux系统是以一个单独的.vhdx镜像文件的方式存在的。开发过程中,体积可能会变得比较大。包括镜像和容器。所以,有了这个问题。下面的工作是将其从C盘转移到容量更大的D盘。

默认wsl的安装位置是系统盘,并且似乎没有直接指定安装目录的方法。

PS C:\Windows\system32> wsl --install Ubuntu-20.04

1.显示当前的所有wsl镜像

PS C:\Windows\system32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

2.终止某个wsl镜像,然后打包,删除该镜像


PS C:\Windows\system32> wsl --terminate ubuntu-20.04
操作成功完成。
PS C:\Windows\system32> wsl --export Ubuntu-20.04 D:\git\wsl\wsl-backup\Ubuntu-20.04.tar
正在导出,这可能需要几分钟时间。 (1965 MB): ./var/snap/lxd/common/lxd/unix.socket: pax format cannot archive sockets

操作成功完成。
PS C:\Windows\system32> wsl --unregister ubuntu-20.04
正在注销。
操作成功完成。

3.在新的路径导入映像,并重新加载 

PS C:\Windows\system32> wsl --import Ubuntu-20.04 D:\git\wsl\Ubuntu-20.04 D:\git\wsl\wsl-backup\Ubuntu-20.04.tar
操作成功完成。
PS C:\Windows\system32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2
PS C:\Windows\system32> wsl -d Ubuntu-20.04
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu Feb 13 10:11:59 CST 2025

  System load:  0.07                Processes:             82
  Usage of /:   0.2% of 1006.85GB   Users logged in:       0
  Memory usage: 8%                  IPv4 address for eth0: 172.22.207.57
  Swap usage:   0%


Expanded Security Maintenance for Applications is not enabled.

164 updates can be applied immediately.
115 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

This message is shown once a day. To disable it please create the
/root/.hushlogin file.

4.校验:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

子正

thanks, bro...

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值