Skip to contentSkip to conversation

defragmenting non-files only

DISCUSSION Eric Wong 1 participant 1 message Jul 27, 2025 Btrfs file system

lore
Share & tools
lore

Eric Wong

author
#0 lore raw

I'm wondering how much fragmentation affects users with large active Maildirs where files are frequently created and removed.

I'm avoiding a blanket btrfs fi defrag -r to reduce storage wear for files which won't live long.

So some questions:

1. how to monitor fragmentation of subvolume/extent tree or anything else which filefrag(8) doesn't seem to report fragmentation for?

2. does btrfs fi defrag $DIR' work only for that directory? In other words, can I btrfs fi defrag $TOPLEVEL_DIR` and expect subdirectories to be defragmented?

Or should I do:

find $TOPLEVEL_DIR -type d -print0 | xargs -0 btrfs fi defrag
?

Thanks.