减少流浪盒存储(vmdk)大小 [英] reduce vagrant box storage (vmdk) size

查看:31
本文介绍了减少流浪盒存储(vmdk)大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 主机上从 ubuntu/trusty64 创建了初始化的 vagrant.我意识到新创建的 virtualbox 的磁盘大小设置为 40GB.我想将其减少到至少 10GB.有没有办法做到这一点?

I created initialized vagrant from ubuntu/trusty64 on Windows host. I realized newly created virtualbox's disk size is set to 40GB. I want to reduce this to at least 10GB. Is there any way to do this?

虽然现在实际大小为 1.19GB,但我不希望它的虚拟大小如此之大.

although right now actual size is 1.19GB i don't want it's virtual size to be this big.

谢谢!

推荐答案

你可以试试看

  1. 通过运行将 vm 中的磁盘空间清零

cat/dev/zero >/path/to/fill/z;同步;睡3;同步;rm -rf z

注意:在运行上述命令之前删除 VM 中不需要的文件.如果您有多个分区、逻辑卷,请在每个分区上进行.

NOTE: Delete unwanted files within the VM before running the command above. If you have multiple partitions, logical volumes, do it on each of them.

  1. 压缩/缩小虚拟磁盘(这适用于 VDI 格式,但不确定 VMDK,您可以尝试)

VBoxManage modifyhd --compact/path/to/vdisk.vmdk

您会看到进度,完成后,检查其大小.

You'll see the progress, once finished, check its size.

更新:如果你想调整虚拟磁盘的大小,你应该使用 VBoxManage modifyhd --resize ;/path/to/vdisk.vmdk.

注意:虚拟磁盘的大小并不重要,它就像它可以增长到的虚拟磁盘映像的上限(最大大小).默认情况下,VMDK 应该是动态分配的,这意味着 vmdk 大小将接近 VM 中的数据量.上述方法将有助于回收来宾内部已释放的空间.

NOTE: The size of the virtual disk doesn't matter too much, it is just like a cap (max size) of the virtual disk image it can grow up to. By default the VMDK should be dynamically allocated, which mean the vmdk size will be close to the amount of data within the VM. The above method will help to reclaim spaces that has been freed up within the guest.

重要:增加虚拟磁盘的大小是可以的,但是在减小/缩小时应该非常小心,新大小的数据可能会丢失<虚拟磁盘中的实际数据大小.

IMPORTANT: Growing the size of the vdisk is OK, but when reducing/shrinking you should be very careful, there is risk of losing data the new size < the actual data size within the vdisk.

这篇关于减少流浪盒存储(vmdk)大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆