25

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 ?

3
  • Most mornern file systems in general do not need to be manually defragmented. This includes ext3, NTFS, UFS and others.
    – Chris S
    Feb 22, 2010 at 21:23
  • 3
    Chris, I can't comment on others but NTFS most certainly does benefit from defrag. It greatly reduces the head thrashing caused by fragmentation and improves response times as a result. Feb 22, 2010 at 22:41
  • @JohnGardeniers Every FS that support fragmentation will benefit from being defragmented. But, it's not necessary and the performance degradation due to fragmentation is limited compared to older file systems.
    – Chris S
    Nov 13, 2011 at 19:37

7 Answers 7

15

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

1
  • Fragmentation adds up though.. I'm trying shake, as suggested by Gert below.
    – blueyed
    Feb 19, 2010 at 1:36
10

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.

7

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

4

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.

2
  • 1
    ext2 and ext3 can be defragmented. They just don't need it in normal circumstances.
    – Eddie
    Apr 30, 2009 at 15:35
  • bear in mind Windows FS never needed to be defragged either - NT3.51 used to allocate space either side of blocks just like ext3 does, but then MS scrapped that in NT4 for some reason.
    – gbjbaanb
    Aug 4, 2009 at 15:24
2

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

2

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .