Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


Search this Thread
Old 11-29-2012, 12:58 AM   #1
LQ Newbie
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
What's the best way to defrag ext3?


I have a web server with centos 5.8.

There are many fragmented files, for example:
# filefrag /home3/files/ZSPNIMTLS2EVSX14ZU2RJYPEX0HU42JGCOJU.avi
/home3/files/ZSPNIMTLS2EVSX14ZU2RJYPEX0HU42JGCOJU.avi: 226 extents found, perfection would be 6 extents

# filefrag /home3/files/YEUBCBYNY02E4VT2ODWUCTAJAY5WVSSGXEEK.avi
/home3/files/YEUBCBYNY02E4VT2ODWUCTAJAY5WVSSGXEEK.avi: 222 extents found, perfection would be 6 extents

# filefrag /home3/files/VMV2SOC3OP0DAVUG1DTIFPX5VHQSPPED4331.avi
/home3/files/VMV2SOC3OP0DAVUG1DTIFPX5VHQSPPED4331.avi: 224 extents found, perfection would be 6 extents
How to reach perfection state?
Currently I get very poor HDD throughput.

Old 11-29-2012, 06:35 AM   #2
Senior Member
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,650

Rep: Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250
see here:
1 members found this post helpful.
Old 11-29-2012, 09:05 AM   #3
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
Hello niri, welcome to LQ,

if you want to defrag a filesystem, you should use Windows.

1 members found this post helpful.
Old 11-29-2012, 03:21 PM   #4
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix
Posts: 766

Rep: Reputation: 172Reputation: 172

EXT filesystems (and most Linux file systems in general) defragment themselves over time. That said, if you use the storage in such a way as to promote fragmentation, moving to EXT4 with delayed allocation seems to help a LOT. On a busy system it reduces fragmentation during new file creation dramaticly, and fragmentation has less impact on performance than it does with EXT3.

There are newer file systems that should have even better properties, but they do not seem quite ready. Yet.

I suspect that your storage performance issues may not be due to fragmentation, but it would take a significant effort to test enough to be sure.
1 members found this post helpful.
Old 11-29-2012, 05:45 PM   #5
Senior Member
Registered: Feb 2011
Location: Australia
Distribution: Debian Wheezy, Jessie, Sid/Experimental, playing with Slackware 14.
Posts: 2,642

Rep: Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554
The easiest way I know of defragmenting ext3, not that it needs it anyway, is to copy the entire system to another drive and then copy it back. The writing process automatically puts the file fragments in their corerct position. I have a system running Debian Sid here and its fragment status is 0.2% I wouldn't think that is an issue.
Old 11-29-2012, 06:41 PM   #6
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,149

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Your best solution, in my opinion, would be to combine the suggestions in the two prior posts (#4 and #5), by copying the ext3 file system into an ext4 one, and using the new ext4 one to replace the old one. Note, however, that you cannot copy system files (/dev, /proc, etc.) and expect things to keep working. (rsync can be used for system files. In fact, consider changing your file system to ext4 and then just restoring the files from your back-ups.) IIRC, you can convert an ext3 file system to an ext4 on "on the fly," but - if I were to attempt that - I'd make sure that I had at least two working back-ups. . .
Old 11-29-2012, 07:49 PM   #7
Registered: Mar 2008
Posts: 11,406

Rep: Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397Reputation: 1397
The old way was to back up to tape as in tar and replace the data. Still works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ext3 defrag terfy Linux - General 22 01-11-2012 03:55 PM
USB Hardrive with FAT32 and ext3 partitions in need of repair/defrag MiniDev Linux - Hardware 6 02-15-2008 03:05 PM
Defrag (NOT for ext2/ext3, for FAT32 partitions) Red Barchetta Linux - Software 2 03-31-2007 07:01 AM

All times are GMT -5. The time now is 04:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration