Hi,
I notice vm qcow2 images grow pretty fast. Also in the backup they are not " deflated".
I have deviced a crude way to deflate the images, but it there a supported way to do this perhaps?
I notice vm qcow2 images grow pretty fast. Also in the backup they are not " deflated".
I have deviced a crude way to deflate the images, but it there a supported way to do this perhaps?
Code:
#to use virt-sparsify below you must install libguestfs-tools
#apt install libguestfs-tools (200 mb)
qm list | egrep -v VMID | awk '{print $1}' > id.list
for id in `cat id.list`; do
echo
echo now processing vm with ID $id
bootstatus=0
file_name=/mnt/pve/backup1tb/images/$id/vm-$id-disk-0.qcow2
if test -e "$file_name"; then
echo file exists : $file_name
### uncomment what you want below
#qm stop $id
#virt-sparsify --in-place $file_name #uncomment to use this: will smallify cow disk
#egrep "onboot: 1" /etc/pve/qemu-server/103.conf
bootstatus=`egrep "onboot: 1" /etc/pve/qemu-server/$id.conf`
#echo bootstatus is $bootstatus #debug
if test -z "$bootstatus"; then
echo "The boot variable is empty, dont boot VM."
else
echo bootstatus is 1, start VM
qm start $id
fi
echo end
else
echo no vm qcow2 file found for this ID
echo aborting
echo
fi
#ls -allah /mnt/pve/backup1tb/images/$id/vm-$id-disk-0.qcow2
done