Does ext3 fragment when run at near-full capacity?

6

3

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?

DWilliams

Posted 2009-09-02T00:32:50.323

Reputation: 824

Answers

3

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.

Sasha Chedygov

Posted 2009-09-02T00:32:50.323

Reputation: 6 616

For some reason the host gives an error accessing the link above. Just shorten the URL and it works, e.g.: http://geekblog.oneandoneis2.org/index.php/2006/08/17/

– casualuser – 2009-11-24T02:34:31.563

According to man page, -a does nothing re: fragmentation, afaik only reports frag levels – ptor – 2009-11-24T15:21:59.443

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 – 2009-11-24T23:28:22.473

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 – 2014-01-21T07:00:09.783

0

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.

darkdragn

Posted 2009-09-02T00:32:50.323

Reputation: 384