My dear fellows,
recently I’ve been searching and studying a lot of information about btrfs, but there is still one particular setup scenario where I would need your help or at least confirmation. It is combination of btrfs, Timeshift snapshots and using your computer as host for QEMU virtual machines.
What I have learned so far (and I really need to highlight THIS HOWTO as it is pure gold and helped me a ton:
- When choosing btrfs during EndeavourOS installation, the installers intelligently creates subvolumes @ (for root), @home, @cache (for /var/cache), @log (for /var/log) and even @swap for storing swapfile with nocow attribute, so there is almost no reason to adjust anything, as the subvolumes layout makes perfect sense
- The above layout, among other things, ensures that certain subvolumes are omitted from Timeshift snapshots, as Timeshift automatically skips subvolumes created/mounted underneath root (@)
- At the same time, however, btrfs is many times considered as not ideal for storing virtual machines, especially qcow2 volumes from KVM/QEMU. It has something to do with double copy-on-write approach, with a lot of fragmentation and low performance
- One recommended approach is to store qcow2 images in a folder which has nocow attribute set (chattr +C) and therefore all files in this folder would be created with copy-on-write disabled
- Unfortunately, as soon as this folder is snapshotted (via Timeshift), copy-on-write is automatically enabled
And now the big question - what to do? Would the following approach be valid?
- Create one additional subvolume, e.g. @vm, set its attribute to nocow (chattr +C) and mount it for example under /vm
- This way, the qcow2 images would be created with copy-on-write disabled, and since the subvolume is mounted under root, Timeshift would exclude it from snapshotting
Looking very much forward to your feedback and advice!