Btrfs image format: compressed vhd or raw copy-on-write?

Which image file format is recommended to chose over a btrfs filesystem?

I tried both for comparison, and here are my findings:

Compressed VHD

Advantages:

  • Initial image and deltas are compressed

Disadvantages:

Raw copy-on-write

Advantages:

  • Offloading deltas handling (and possibly compression) to the filesystem
    • How does the btrfs compression compares to the native VHD compression? [edit: 7% worse (zstd:4)]
  • Allows “incremental forever” image backup scheme
  • Each incremental backup is a fully assembled RAW file (no need to build it using external tools)
    • However, how can this RAW file be used? Can it be mounted like a VHD file? [edit: YES from the command line, NO from the web interface]

Disadvantages:

  • Initial image and deltas are not compressed by default.
    • Filesystem should be mounted with compress-force? [edit: YES! see my post below for comparison]
      • What implications does forcing compression have on other files (e.g. JPEG, MP3, MKV from file backups)?
      • Would it make everything slower by trying to compress incompressible files? [edit: YES, but there could be other bottlenecks like disk and network speed]
      • Would it use more RAM [edit: insignificant] and possibly even more disk space? [edit: probably not]

I’m still gathering the missing info, but I’d love to hear from people who already did this research!

EDIT: After some more research, I have updated my post. My conclusion is to use raw copy-on-write with the compress-force mount option.

I cant answer your question, but have you thought of that you can compress btrfs directly. You just mount it and tell it to compress (and what level) and it compresses it on the fly. General rule is more compression = slower read/write ofc, but a little compression actually increased write and read speeds on my personal computer. I use zst:9. But if speed is not an issue rather than space, why not go full blast? xD

https://btrfs.readthedocs.io/en/latest/Compression.html

I don’t think you should let your choice of filesystem decide what method you use to create an image.
You have a very nice pros and cons list there. Make a decision from that, what is most important to you?

Btrfs compression is turned on, but it treats image backup RAW files as incompressible, unless the compress-force mount option is used, but then it possibly has other implications (see my original post).

What do you base the assumption that compression on btrfs won’t work for certain files?
Where did you get that mount option from?

Edit
Do you mean compress-force?

If compress-force is specified, then compression will always be attempted, but the data may end up uncompressed if the compression would make them larger.

So again, what makes you so sure the files will be larger?

(It’s good you are making your research before doing stuff!)

Edit 2
“GREAT BEDNA, (fkn dyslexia) he fkn WROTE compress-force, but your brain just HAD to make a fool of yourself huh?”
Sorry about that.
Question still stands though, what makes you think the compression wont work? If you set it to max I think it will compress, but I also have no data to back that claim up…
Besides, why would that option be a bad idea if you actually WERE forced to use it?

With regular compress mount option, the image file did not compress (111GB on disk):

Processed 1 file, 16992 regular extents (16992 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       99%      111G         112G         112G
none       100%      111G         111G         111G
zstd        35%       85M         242M         242M

However with compress-force, compression finally kicked in (59GB on disk):

Processed 1 file, 784669 regular extents (784669 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       55%       59G         108G         108G
none       100%       25G          25G          25G
zstd        41%       34G          83G          83G

I have updated my original post with the new info.

What is “regular compression options”? At the top of my mind I can find at least 25 compression mount options that could be considered standard. If you are going to call this a tutorial thread, at least explain HOW you mounted it that “do not work”. What compression method of the 3 available for btrfs did you try? What level of compression with the different levels each kind of compression allows did you try???

I repeat, WHY do you need that option???

Edit
I see… You tried:

Witch means you use one of the absolute lowest compression levels possible, and you are surprised that compresses LESS than forcing max compression with compress-force.

Ok buddy.

I on the other hand feel pretty confident that if you raised the compression level to max, like I suggested you do, you will get VERY simular results, but without forcing btrfs into anything but rather letting it do what is the best method. As a matter of fact, as it even states in the btrfs documentation, using max could make the files bigger, so this is an art of trying to find the best compression level for the data you store.
I would start with 10 and move upwards to max and find what is best. Maybe zstd is not even the most efficient here!

But you do you, I just want OTHER ppl to see this is not accurate,