I have a /home partition in a separate disk with XFS, how do I de-fragment it ? (on-line or off-line)

I haven't tried anything yet and the / partition has BTRFS. Also how to schedule it would be nice. But I can check that out in already responded questions.

This was the output :

sudo xfs_db -c frag -r /dev/sdb5
actual 329394, ideal 301436, fragmentation factor 8.49%

1 Answer 1


XFS provides a filesystem defragmentation utility, xfs_fsr that can defragment the files on a mounted and active XFS filesystem.

It can be useful to view XFS fragmentation periodically.

xfs_fsr improves the organization of mounted filesystems. The reorganization algorithm operates on one file at a time, compacting or otherwise improving the layout of the file extents. Inspect fragmentation levels

To see how much fragmentation your file system currently has:

sudo xfs_db -c frag -r /dev/sd??

To begin defragmentation, use the xfs_fsr command which is included with the xfsprogs package.

sudo xfs_fsr /dev/sd??

Change ?? to what corresponds your partition


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.