しかし、仮想マシン内でファイルの作成と削除を繰り返すと徐々にサイズが大きくなってしまう。
これを圧縮する方法。
■最初の状態
# ll -h
-rw-r--r--. 1 root root 16G 5月 9 00:48 centos62_x64_master-clone.qcow2
■qemu-img の convert と圧縮を利用する。
# qemu-img -h
qemu-img version 0.15.1, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
QEMU disk image utility
Command syntax:
convert [-c] [-p] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] filename [filename2 [...]] output_filename
Command parameters:
'filename' is a disk image filename
'output_filename' is the destination disk image filename
'output_fmt' is the destination format
'options' is a comma separated list of format specific options in a
name=value format. Use -o ? for an overview of the options supported by the
used format
'-c' indicates that target image must be compressed (qcow format only)
Supported formats: rbd tftp ftps ftp https http host_cdrom host_floppy host_device file blkverify sheepdog blkdebug nbd parallels qed qcow2 vvfat vpc bochs dmg cloop vmdk vdi qcow cow raw
■変換を実施
# qemu-img convert -c -O qcow2 \
> centos62_x64_master-clone.qcow2 centos62_x64_master-clone.qcow2.new
■変換後の状態
# ll -h
-rw-r--r--. 1 root root 16G 5月 9 00:48 centos62_x64_master-clone.qcow2 -rw-r--r--. 1 root root 1.3G 5月 9 01:06 centos62_x64_master-clone.qcow2.new1/10以上の圧縮効果。
起動確認をしたら前のイメージは削除する。
0 件のコメント:
コメントを投稿