有效减少虚拟机镜像文件的大小

2 篇文章 0 订阅
使用该方法后我们项目制作出的镜像大小在2.7G
而如果不做清理我们项目制作出的镜像会有18G

为了制作的img文件较小,我们需要先清理虚拟机中的垃圾。
1.交换区做为硬盘上被划为内存使用的区域,里面的内容是可以清理的。
2.把空闲区域的磁盘0格式化。

Shrinking the Disks
When you export your VMs in your OVF package you want to make sure
that all unused space is zeroed out, since this compresses really well
in the VMDK disk format. However, space used by swap disks and deleted
files often take up space on disk, since they are not eagerly zeroed
out by default by most operating systems. This means that even though
your VM says it only uses about 500 MB it may actually take up a lot
more space. Even worse, you may have confidential information on, e.g.,
your swap drive or old deleted files that you do not want to distribute
with the OVF package. There are several ways to solve this problem. On
most Linux distributions it is possible to do the following things to
clean up a disk before you export the VM: 1) Un-mount the swap drive;
2) Write a single file to disk containing only zeroes as large as
possible; 3) Delete the file immediately after you created it. On the
command line you can do these three steps by invoking these commands:

1. /sbin/swapoff -a (this will un-mount all swap disks)
2. dd if=/dev/zero of=zeroFile.tmp
3. rm zeroFile.tmp


使用vsphere制作ovf/ova img
stop the vm
In the vSphere Web Client, navigate to a virtual machine or vApp and select Export OVF Template from the Inventory Actions menu.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值