Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know Windows file systems are very sensitive to fragmentation and Unix such as UFS, ZFS, ext3, or ext4 are not as sensitive.

But, is there any reason to defragment these filesystems at all?

If so, what tools are available for that ?

share|improve this question

7 Answers 7

up vote 15 down vote accepted

Quoting Wikipedia's page about the Ext3 Filesystem

Modern Linux filesystem(s) keep fragmentation at a minimum by keeping all blocks in a file close together, even if they can't be stored in consecutive sectors. Some filesystems, like ext3, effectively allocate the free block that is nearest to other blocks in a file. Therefore it is not necessary to worry about fragmentation in a Linux system

share|improve this answer

Actually, NTFS is not that sensitive to fragmentation. NTFS is significantly better than FAT32 -- in every way -- and is a fully modern filesystem.

I've been running Linux at home since 1996 and have never defragmented any filesystem. I have never had the need. The most I have done in this direction was pay attention to the kind of files I will be putting on a filesystem and using appropriate options when I mkfs. For example, if a filesystem will primarily contain large files, I'll use a larger block size. If I am making a huge file system but I know it will never have more than 1,000,000 files, then I'll use the -N 1000000 option to limit the number of inodes. In general, I'll tune the filesystem at creation to its task if a particular kind of file will inhabit it.

share|improve this answer

You don't need to defrag no. But if you still want to do it, you can always use shake.

share|improve this answer

While ext2 and ext3 do not provide for it (and generally need it less as they keep files relatively together in the first place) ext4 does provide for defrag. This article talks about the e4defrag program. But ext4 is a new filesystem.

However, compared to windows linux file systems are much better at not fragmenting, so I wouldn't worry about it.

share|improve this answer

http://en.wikipedia.org/wiki/Ext3#Defragmentation, but I wouldn't bother

share|improve this answer

The only good reason for defragging linux filesystem is to shrink virtual hard disks that have bloated.

Zero fill unused space, defrag and then compact the virtual disk from the VM manager.

share|improve this answer

You can defrag XFS file system (using xfs_fsr [dev|file]) and btrfs (using btrfs filesystem defragment [file]

As for all others, just make sure you have at least 80% free or few dozen gigabytes (whichever is smaller) and you shouldn't worry about defragmentation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.8.22.1792\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Server Fault works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscr"], "copyright__copyright__copyright": [" this answer\n\nYou can defrag XFS file system (using xfs_fsr [dev|file]) and btrfs (using btrfs filesystem defragment [file]\n\nAs for all others, just make sure you have at least 80% free or few dozen gigabytes (whichever is smaller) and you shouldn't worry about defragmentation.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}