Imagine you set up your root filesystem to be btrfs with Ubuntu 14.10 defaults (one subvolume for / and one for /home) and you want to compress and deduplicate as much as possible. Which directories should be managed as a proper subvolume and disabled for compression? The two targets "compress as much as possbile" and skip compression of certain parts for performance reasons are mutually exclusive, therefore let me clarify the question:

  • Certain sets of files and directories seem to suffer from compression (e.g. dpkg takes up to 30 minutes reading the package list after update) (with zlib compression after btrfs filesystem defragment -c) disabling compression for /var/lib/dpkg/ speeds up things by factor 1000. Are there further examples for such performance impacts (dpkg's database isn't very performant).
  • Directories containing source code (/src/ and others) are good candidates for compression although they will be mostly read when the system compiles and therefore the CPU load will be high and CPU-intensive decompression has to be done. How to estimate or measure the tradeoff?

1 Answer 1


I believe that per-subvolume compression is not available yet. From the BTRFS wiki:

Most mount options apply to the whole filesystem, and only the options for the first subvolume to be mounted will take effect. This is due to lack of implementation and may change in the future.

This means that (for example) you can't set per-subvolume nodatacow, nodatasum, or compress using mount options. This should eventually be fixed, but it has proved to be difficult to implement correctly within the Linux VFS framework.

Unless you have information to the contrary, your plan won't work (yet).

  • I'd love for it to work one day though! I'd suggest that ~/Downloads would be one worth skipping compression on, and ~/Pictures. ~/Documents would probably compress well though. However, I don't think it would be worth the effort to make that many subvolumes just for compresssion - btrfs should detect if a file compresses and stop trying if it doesn't.
    – seanlano
    Apr 13, 2015 at 12:28
  • The above Wiki page is marked obsolete now. However, the docs still state the same: btrfs.readthedocs.io/en/latest/… :-(
    – Lemming
    Oct 4, 2023 at 8:04
  • Would it help to enable compression per directory, e.g. btrfs property set /mydir compression zstd?
    – Lemming
    Oct 4, 2023 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .