The default option for creating a new block storage image for qemu2 is to create an image that's as large as the memory + allocated disk size. For example, here is what "ls -l" reports for a new Ubuntu 16 VM with 10 Gigs of memory and a 200 Gig HD.
Size Name 214,781,394,944 VMNAME.qcow2
Most of that 214 GB is blank, but how can you easily shrink the disk space for an already running VM? Easily, with a snapshot and consolidation with blockpull. In making a snapshot qemu2 is smart enough to figure out which parts are unused and create the compressed image only as large as needed. To do this we can use LibVirtKVM-scripts and specifically fi-backup with -C and "-m blockpull"
First make sure the VM is running and if not ...
virsh start VMNAME
Then run
sudo fi-backup.sh -C -m blockpull VMNAME
and after it's done lets take a look at the size of the disk
Size Name 1,841,954,816 VMNAME.bimg-20171214-111200
which has shrunk it's physical space on the OS to about 0.9% of it's previous size. From 214 GiB to 1.8 GiB. Now you can transfer network backups of VM shapshots in a fraction of the time.
So if blockpull is so great - why not use it for everything? Because it is Sloooooooooooooooooooooow.
Blockpull creates a brand new file from scratch starting at the beginning of the old backing files. For a large file like this on a speedy, SSD-based server it can be over 30 minutes. This is a disadvantage if you have multiple images to back up, it consumes resources while it is running and impacts performance of the VM and host server.
So the best practices is if you have this situation, run a blockpull backup once to shrink the size of the physical VM file. Then run blockcommit backups from then on where the consolidation will take 1-2 seconds.
- Log in to post comments