

#Btrfs recompress for free#
'df' shows the raw physical blocks that are used and free, which means it's (unknowingly) accounting for compression for used space reporting, and assuming no compression for free space. Q: How is used and free space reporting affected by compression?Ī: It depends. they may be annoying but they're not risking your data. Q: Is there a list of compression related bugs?Ī: Known compression related bugs are cosmetic, i.e. Q: Do I have to reboot to change compression options?Ī: No, you can just remount any mount point for that file system, specifying the new options, e.g. So that does mean the filefrag tool is not a reliable indicator of file fragmentation. The actual physical extent on disk may be contiguous, but FIEMAP currently doesn't have a way of knowing this. This 128KiB extent is actually the maximum compression block size. The 'filefrag' command uses FIEMAP, and this reports the Btrfs logical address in what appears to be separate, non-contiguous, 128KiB extents. Q: Does compression cause more fragmentation? The 'filefrag' tool shows a lot more extents on compressed files.Ī: No. Q: Is it safe to mix and match compression algorithms? Even if you get 'btrfs property' to set it with 'zstd:1' it will use 3. Q: If I use 'btrfs property' to set compression, what level is used for zstd?Ī: Currently the default is always used, level 3. Q: How are 'chattr +c' and 'btrfs property' the same?Ī: Internal to Btrfs they both set a compression flag on the inode. Whereas +c (small c) stands for compression. Tip: COW stands for copy-on-write so 'chattr +C' (capitalized) means nodatacow. And zlib also applies if you use the compress(-force) mount option without specifying an algorithm. However you can't specify an algorithm like you can with 'btrfs property' so it uses the current default, zlib.

The 'none' option doesn't unset compression, it prevents the compress mount option from working.Ī: This is the legacy way of setting compression before 'btrfs property' existed, and still works today. The 'btrfs property' command can be used to set compression per subvolume, directory, or file. Q: Is there a way to do it per subvolume?Ī: Yes, but there are some caveats. The compress(-force) mount option is file system wide, it applies to the entire fs, not per subvolume or mount point. Save and reboot or mount -o remount,compress=none / Q: I want compression only on '/' and not on '/home', can I just modify fstab?Ī: No. This was originally scoped as an optimization for during Fedora 33.įeedback Q: How do I disable this feature?Ī: Edit '/etc/fstab' and remove the 'compress=zstd:1' mount option. Depending on the workload and the hardware, compression can also result in an increase in read and write performance. Enabling compression saves space, but it also reduces write amplification, which is important for SSDs. Of the three supported algorithms, zstd is the one with the best compression speed and ratio. Transparent compression is a btrfs feature that allows a btrfs filesystem to apply compression on a per-file basis.

1.5.9 Q: Do I have to reboot to change compression options?.1.5.8 Q: Does compression cause more fragmentation? The 'filefrag' tool shows a lot more extents on compressed files.1.5.7 Q: Is it safe to mix and match compression algorithms?.1.5.6 Q: If I use 'btrfs property' to set compression, what level is used for zstd?.1.5.5 Q: How are 'chattr +c' and 'btrfs property' the same?.

1.5.3 Q: Is there a way to do it per subvolume?.1.5.2 Q: I want compression only on '/' and not on '/home', can I just modify fstab?.1.5.1 Q: How do I disable this feature?.1 Enable btrfs transparent zstd compression by default.
