How does Linux avoid filesystem fragmentation?


Recommended Posts

...no. I can tell you, it does fragment.

I've read page up and page down about the ext2 filesystem and how great it is, but what it basically boils down to, is that it splits the partition into "clusters", and places a "superblock" in front of every one. What this acomplishes is that files are scattered all over the disk, and thus there is less risk of fragmentation.

But! What happens if you do the following:

- Create a small file (#1)

- Create many (and then I mean so many that the space after file #1 is filled) other files

- Update file #1, (like adding 20 8MB files to it)

In my experience, it gets fragmented. This was what happened on my /boot partition. There was a lot of files stored there (for GRUB), and my default kernel image. I created a few new kernel images, and then I replaced the original with a new one(there was a new kernel out). The check showed 37% fragmentation.

The partition in question was 64MB and formatted with ext2. I know XFS also uses the "grouping" of files into clusters, but dunno how this works with ReiserFS or JFS. My guess is that ReiserFS have potential for fragmentation.

I hope someone can comment on this, correct me where I'm wrong, and perhaps suggest solutions to my problems.

PS: There is one solution that works in most cases, that is backing up all files, wiping the partition, and restoring them.

Link to comment
Share on other sites

Well, the Windows defragmenters do have some nice feats, the XP one arrenges all files used at boot time, with ext2 and the like you risk having a lot of core system files spread all over your disk.

I'm just surprised that noone is working on a defragger. It seems everyone wants to tweak the penguin in all other aspects but this one. :unsure:

Link to comment
Share on other sites

I guess they figure (if Linux does even have this problem) that fragmentation is a small problem right now compared to getting the OS more friendly.

Linux ext2 file system suffer very little from fragmentattion. so it doesn't need this kind of tools. While FAT32 and NTFS need defragmentation tools, this doesn't apply to Unix/Linux file system.

ext2/ext3 file management is much more efficient than NTFS/FAT32, esp for large files.

and actually the fsck, or e2fsck has the built-in functionality for defragmentattion for my ext3 file system. (not sure ext2)

no need to worry

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.