Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that one of the main drawing points for ex3 and other journaling filesystems is that they do not fragment like NTFS and such.

I once heard someone say that ext3 actually would fragment when operated at near-full capacity for a length of time. Is there any truth to this? I've been running my main home ext3 partition at 95%+ capacity for at least a year and would like to know if this is actually causing any fragmentation, and if so does it clean up after itself automatically?

share|improve this question
up vote 3 down vote accepted

Technically, yes, it can fragment if there is not much free space available, and no, it doesn't clean up after itself. To check the fragmentation level of a partition:

fsck -nvf /dev/sda1 # replace sda1 with the relevant partition

and to see how fragmented a particular file is:

filefrag -v /path/to/file

Here is an article about how to defrag a Linux system, but chances are it is not affecting your system to a noticeable degree, so you don't need to worry about it.

If you're really interested, this article and its follow up were extremely helpful to me in understanding how the file system works.

share|improve this answer
For some reason the host gives an error accessing the link above. Just shorten the URL and it works, e.g.: – casualuser Nov 24 '09 at 2:34
Thanks for noticing, I fixed it. – Sasha Chedygov Nov 24 '09 at 4:59
According to man page, -a does nothing re: fragmentation, afaik only reports frag levels – ptor Nov 24 '09 at 15:21
Ah, okay. Found a more legit article that shows how to defrag a Linux system using Shake. Just note that I wouldn't recommend doing this in most cases, as it's probably unnecessary. – Sasha Chedygov Nov 24 '09 at 23:28
How do you list all non-contiguous files along with their number of chunks? For example, filesystem may have just one file fragmented to 10000 chunks. And if this file is used much, performance penalty may seriously rise. But a percentage of non-contiguous files will be like 0.01% in this case. – Vladislav Rastrusny Jan 21 '14 at 7:00

Here's the thing, if you want to find out just fsck the drive. In other words, plug it in, find out it's 'name,' which will usually be /dev/sdb unless you have multiple hard drives, run fdisk -l to get the partition number and finally e2fsck -f /dev/$partition.

Ex: e2fsck -f /dev/sdb1

e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/dataSet/oldRoot: 295731/1310720 files (2.7% non-contiguous), 2034611/5242880 blocks

The non-contiguous remark is the percentage of fragmentation. On the old ext2 partitions I saw this number get pretty high, however with ext3 and ext4 I have usually never seen it get outside of the single digits. In comparison to a NTFS volume which will usually sit around 40% this is a negligible amount of fragmentation.

share|improve this answer

You must log in to answer this question.

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