I have been experimenting with putting /var/lib/libvirt/images on a
btrfs subvolume. What I found was ... interesting.
Just doing nothing else, a disk image file can en up with something like
50,000 extents or more. Now, you can go do a btrfs fi defrag and it
will reduce but when you use the system, it will increase again.
OK, you cannot turn off "cow" for a subvolume but you can turn it off
for a new file (or more important) for an new file in a directory:
chattr +C /var/lib/libvirt/images and any new disk image file will have
no-cow.
OK, install a system with a new disk file. The result: a file with
47,000 extents. The reason, I used virt-manager and the disk image file
allocated was a sparse file. Now in some respects sparse files are good
because they do not use space unless they need it. But, with BTRFS, the
result is large scale fragmentation. And, btrfs fi defrag does not
work on this file /directory.
OK, another try. Preallocate a file using dd if=/dev/zero
of=/var/lib/libvirt/images/xxx.img bs=1024 count=12587000 and the result
is a 12GB (more or less) virtual disk. Install a system using this as
the virtual disk. extents=9. install a second system subvol=root2 (it
is a virtual btrfs system). extents=9. And a third one. extents=9.
BTW, these installs were about the fastest I have ever seen!
So, is there a way to do this "sparse=false" disk allocation with
virt-manager, or do I need to do an RFE?
For a system where the disk images are going to be on BTRFS, a fully
allocated disk has definite benefits.
Gene