Defragmenting and Compressing a Btrfs File System
You can defragment the file system to increase I/O performance. You can also compress a Btrfs file system to increase its effective capacity.
You can defragment the file system or any files and directories within the file
system by running the btrfs filesystem defragment
command. You can
automatically run defragmentation on the file system by setting the
autodefrag
option when you mount it. However, note that automatic
defragmentation isn't recommended for large databases or for images of virtual machines.
Note:
Defragmenting a file or a subvolume with a copy-on-write copy breaks the link between the file and its copy. For example, if you defragment a subvolume that has a snapshot, the disk usage by the subvolume and its snapshot increases because the snapshot is no longer a copy-on-write image of the subvolume.
zlib
: General-purpose and widely used compression with balanced speed and compression ratio.lzo
: Rapid compression and decompression with a lower compression ratio than other options.zstd
: High compression ratio and rapid compression and decompression.