Prepare VM disk before snapshot and compress

disk

# 70GB disk space zeroed by
dd if=/dev/zero of=/zerofile bs=1M count=70k
rm /zerofile

swap

# zero to 1GB swapfile (or partition)
swopoff -a
dd if=/dev/zero of=/swapfile1 bs=1M count=1k
mkswap /swapfile1
swapon -a

Compress qcow2 image

qemu-img convert -O qcow2 -c /opt/stack/data/glance/images/8be7ab01-5140-4d51-bf5d-b0bcb65e8d61 /storage/openstack/jira-2017-10-08-zip.qcow

Compress results

-rw-r----- 1 1024 users 7.5G Oct 8 13:23 db-2017-10-08.qcow
-rw-r--r-- 1 1024 users 1.9G Oct 8 13:45 db-2017-10-08-zip.qcow
-rw-r----- 1 1024 users 6.4G Oct 8 13:26 home-2017-10-08.qcow
-rw-r--r-- 1 1024 users 2.9G Oct 8 14:05 home-2017-10-08-zip.qcow
-rw-r----- 1 1024 users 5.3G Oct 8 13:56 jira-2017-10-08.qcow
-rw-r--r-- 1 1024 users 3.6G Oct 8 14:00 jira-2017-10-08-zip.qcow
-rw-r----- 1 1024 users 3.8G Oct 8 13:24 noc-2017-10-08.qcow
-rw-r--r-- 1 1024 users 1.4G Oct 8 13:40 noc-2017-10-08-zip.qcow
-rw-r----- 1 1024 users 8.0G Oct 8 13:22 wiki-2017-10-08.qcow
-rw-r--r-- 1 1024 users 5.5G Oct 8 13:36 wiki-2017-10-08-zip.qcow

Compress ratio for different images

ImageDiskSize1Size2%description
db20G7.5G1.9G25%postgresql
wiki80G8.0G 5.5G68%attlassian confluence
jira80G5.3G3.6G67%Atlassian jira
home20G6.4G2.9G45%nginx
noc20G3.8G1.4G36%zabbix

size1 - size after disk export from open stack

size2 - size after disk compress by qemu-img



  • No labels