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.

7 comments:

michalmazur said...

Thanks! Fast and simple, as I needed:)

while1 said...

Ok, you don't type emerge install on gentoo.

# emerge xfsprogs xfsdump

is the right command for installing the packages needed.

Nikolay V. Nemshilov aka St. said...

Good point, thanks

Isaac Dansicker said...

I would point out that on Gentoo systems, you need to emerge xfsprogs just to run.

Also what would you call scary? My Movies partition is at 49.52% that seems high to me.

Mike said...

gus3's comment on
this story
has me somewhat nervous about using xfs_fsr. Has anyone tried this recently? I've got a severely fragmented 1TB drive on my media center box and it's giving a very noticeable impact hit. I foolishly don't have backups of everything at the moment since I lack the storage and am too lazy to burn a few hundred gigs of data to DVD's, hence the timidness.

Nikolay V. Nemshilov aka St. said...

Hey Mike,

I used it in June to defrag my 750G storage, everything went without problems. Maybe that guy had some mechanical problems with his hdd or used some unstable build.

But anyway. You should use the situation as an excuse to buy a new bigger HDD ;)

Mike said...

Many thanks for the quick reply. This is very good to know. Nice blog, by the way.