开发者

How to Compress or write zero's /dev/zero to a swap file?

We have a few linux based (Centos) virtual machines which are to be used as distributable virtual appliances. We want to be able to compress them as much as possible for distribution ( via tar.gz, zip, etc).

We've removed all unnecessary files (.log's, /tmp/*, /var/log/, etc) and have written /dev/zero to the free space on the disk.

Is it possible开发者_运维知识库 to write zeros via /dev/zero to the swap partitions and files? I know I would need to swapoff -a first. I'm worried about corrupting any internal structures.

Our vm uses both partition swap and file swap.

Also, are there any other strategies for reducing the size of a VM for distribution?

We need to support all of the hypervisor technologies (Xen, VMW, etc), so although the vendors tools maybe useful, I'm looking for strategies that are cross platform.

--- Thanks


You may want to write zeroes and then use mkswap to create an empty swap partition.


$ dd -if=/dev/zero of=/path/to/file bs=512 count=1 adjust the size that you want your files to be.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜