Tuesday, February 5, 2008

How to defragment your XFS partition

If one beautiful morning, you like me found yourself having performance problems with reading from your huge XFS partition, you probably will think about defragmentation for the partition (at last if you had former windows experience). And will be right, case XFS in difference of ReiserFS needs a defragmenation. So this is how you may do it.

First you'll need to install some packages.

On your ubuntu/debian/suse whatever if you use the apt-get utility, say this.

# apt-get install xfsdump


Under Gentoo, this

# emerge xfsprogs xfsdump


Then you'll need to check if your partition needs a defragmentation in really

# xfs_db -r /dev/sda5
xfs_db> frag
actual 22222222, ideal 2342342, fragmentation factor 99.9%
xfs_db> quit


Once you see a scary fragmentation factor, run the command for the optimization

# xfs_fsr -v /dev/sda5
.......


That's it, now you may go have a drink, lift something heavy, play the guitar or pay an attention to your girlfriend. This whill take some time.