Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Do ext4 filesystems need to be defragmented? If so, how do I defragment them?

If not, could you post a simple explanation of why they do not need to be defragmented?

share|improve this question
2  
If you are as interested as you sound, perhaps this paper would be of interest regarding this: Fedora Project, specifically starting at page 179 (which is really page 3) –  nerdwaller Jan 15 '13 at 21:39
    
@nerdwaller Interesting, though a little to in-depth for me to fully comprehend. –  BenjiWiebe Jan 15 '13 at 21:42
1  
Related question on Ask Ubuntu: Why is defragmentation unnecessary?, where the current accepted answer is: The underlying filesystems used by Ubuntu, like ext2 and ext3, simply don't need defragmenting because they don't fragment files in the same way as NTFS. There are more details athttp://en.wikipedia.org/wiki/Ext3#Defragmentation. –  Breakthrough Jun 14 '13 at 17:28
add comment

2 Answers

up vote 4 down vote accepted

Do ext4 filesystems need to be defragmented?

Yes (but very rarely).

If so, how do I defragment them?

Copy all the files off the partition, erase the files from the partition, then copy the files back onto the partition. The file system will intelligently allocate the files as you copy them back onto the disk.

If not, could you post a simple explanation of why they do not need to be defragmented?

ext4 acts in a more intelligent way than merely adding new files into the next available space. Instead of placing multiple files near each other on the hard disk, Linux file systems scatter different files all over the disk, leaving a large amount of free space between them. When a file is edited and needs to grow, there’s usually plenty of free space for the file to grow into. If fragmentation does occur, the file system will attempt to move the files around to reduce fragmentation in normal use, without the need for a defragmentation utility.

share|improve this answer
    
So there is no on-demand defragmenter software? –  BenjiWiebe Jan 15 '13 at 21:42
2  
@BenjiWiebe If I knew of one I'd say but please do not read into the fact that I do not know anything more than that I am ignorant! But bearing in mind I gather that by nature there will be no chance of fragmentation of an ext4 disk less than 80-95% occupied and that copy/delete/reinstate is recommended, why would anyone bother to create such software? –  pnuts Jan 15 '13 at 22:44
2  
A link to the source you copy/pasted from never hurts... ;) howtogeek.com/115229 –  Christophe L Nov 17 '13 at 2:10
    
@ChristopheL Agreed. I do usually attribute but the page you mention does not look familiar to me (mind you, from nearly a year ago) so I wonder whether I picked up most of the wording from a forum that showed the quote but did not itself attribute it. –  pnuts Nov 17 '13 at 8:14
add comment

I have been using ext4 partition for over a year. I often run out of space, moved a lots of files in and out etc etc... these things are bad for fragmentation and yesterday I checked for fragmentation for the first time and only 2 files (not % just two files) were fragmented

on windows partition that was used for about a year longer with much more free space available I have 95% fragmentation...

so no you really dont need to defragment ext4 and if you want to be sure, leave the default free space for ext4 (default is 5%, can be changet by ex2tunefs -m X)

share|improve this answer
add comment

protected by Breakthrough Jun 14 '13 at 17:18

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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