Defragment XFS File-system

Posted 12 Dec 2007 - 6:52pm by xiaofeng




Linux: How to defragment XFS
I have been using XFS file-system for all my Linux box for quite some time now. XFS have some fancy features such as live file-system defragmenting. Let's cover how to do that.
First, make sure you have the xfsdump utilities install. For Ubuntu or its derivatives distribution, simply issue this command:
sudo apt-get install xfsdump
Then, optionally you can check how fragmented your file-system is by this command:
sudo xfs_db -r /dev/hda1 xfs_db> frag actual 300086, ideal 299315, fragmentation factor 0.26% xfs_db> quit
In my case, my root is /dev/hda1. You need to reply with the device node containing your file-system you want to check.
How to defragment? Simple. Just invoke this command:
sudo xfs_fsr -v /dev/hda1 / start inode=0 ino=1278965 extents before:2 after:1 DONE ino=1278965 ino=2114947 extents before:2 after:1 DONE ino=2114947 ino=3912996 ... ino=254717564 extents before:2 after:1 DONE ino=254717564
Or you could just run xfs_fsr with no parameters. It will defragment all mounted XFS file systems by default, and will even start where it left off the next time it is run.
forgot to ask a question I have...
I'm a bit of a noob, just started using XFS file system, which has worked very well so far.
However, your statement above: "You need to reply with the device node containing your file-system you want to check."
Where or how do I find the "ino=?" value?
I'm not sure how to get that.
Thanks,
Kevin LS
found your page thanks to google.
Thanks for the info about XFS!
Best Wishes
Kevin LS