ButterFS, like ZFS but does not eat all of your ram.
Some options I use
rw,noatime,compress-force=zstd:1,ssd,user_subvol_rm_allowed,autodefrag,subvol=@
Kernel cmdline needs only this because systemd will remount the root with correct options anyway
root=LABEL=ROOT rootflags=subvol=@
This was needed on kernels between 5.6 and 6.2. Newer kernels are running async discard by default.
This was needed only on realy old kernels (<4.5). Now defaults to space_cache=v2
Since 6.7 you can enable simple_quota space accounting on subvolumes. It's a lightweight more performant alternative to normal quota accounting.
btrfs quota enable --simple /
Drawback is that simple_quota
is aqurate only for subvolumes (not snapshots) and only for data that was written after simple_quota
was enabled (there is currently no rescan option like in classic quota system). This works pretty well for figuring out how much disk a systemd-nspawn container uses.
NB: Kernels before 6.11 do not automatically cleanup quota groups left over after a subvolume/snapshot is deleted. You need to manually run btrfs qgroup clear-stale /
to clean them up.
NB: Simple quota group removal can trigger a kernel bug if the qgroup size is 0
Files created using fallocate(2) break btrfs.
Reproducer:
# fallocate -l 128m data
# compsize .
Processed 1 file, 1 regular extents (1 refs), 0 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 100% 128M 128M 128M
prealloc 100% 128M 128M 128M
# truncate -s 128m data
# compsize .
Processed 1 file, 1 regular extents (1 refs), 0 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 100% 128M 128M 4.0K
prealloc 100% 128M 128M 4.0K
# stat data
File: data
Size: 4096 Blocks: 8 IO Block: 4096 regular file
This mostly problem for databases (PostgreSQL, Prometheus) and torrent clients that by default fallocate all their files.
btrfs subvolume list
with btrfs-list https://github.com/speed47/btrfs-listcompsize