LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Does a Linux system get fragmented when 20% or less is free (https://www.linuxquestions.org/questions/linux-general-1/does-a-linux-system-get-fragmented-when-20-or-less-is-free-517548/)

HGeneAnthony 01-08-2007 07:49 PM

Does a Linux system get fragmented when 20% or less is free
 
I've heard before Linux systems don't get fragmented. I read a guide why and it seemed pretty interesting. However, one thing I thought of was that a Linux system will not get fragmented as long as there's say 20% free space available. What I'm wondering is if almost all the space is taken will the partition become fragmented? More importantly if the space is freed up again will Linux correct the partition?

Okie 01-08-2007 07:58 PM

Linux does not make a mess out of the system like Windows does so defragmenting is not necessary, as something as important as this i would tend to think the top dawgs that develop Linux and the GNU tools would have made a defragmenting utility for it...

i have a Slackware-10.2 install well over a year old that never gives me problems...

shorty943 01-08-2007 08:01 PM

Unlike some other OS's, Linux does not put little pieces of a file all over the place. The Linux filing system puts all of the file, any file, in the one cubby hole. So there is never any file fragmentation. If your system is getting cluttered, it may be log files, Linux logs lots. Search your system, and rid it of old log files. Maybe even buy a bigger hard drive and install it as a new /home/user partition. Myself, I don't have space problems. Installed a raid set of 4x40Gb disks to my server, got me big bit bucket.
Linux does not fragment like MS Winslows, period.

Shorty943.

registered Linux user 437639

HGeneAnthony 01-08-2007 08:22 PM

Reply
 
I saw the way Linux organizes files. If I got this right Windows stores their files:

aaaaaaabbbbccccc****************************
********************************************
********************************************
********************************************

If someone deleted file b and created d it would be added like this:

aaaaaaaddddcccccddddddddeeeee***************
********************************************
********************************************
********************************************

b is deleted and d is first written to the space that b left over. d then writes the rest to the next area of free space. Hence the data is fragmented. Linux on the other hand writes the data.


***************aaaaaaa**********************
***************bbbb*************************
***************ccccc************************
********************************************

So when b is deleted, d is written in it's place which avoids fragmentation. However if Linux has very little space left it can't possibly use this method and would need to look for free space anywhere it could. So how could this not get fragmented?

shorty943 01-08-2007 09:17 PM

Quite simple. Stop thinking the Microsoft way. Just stop thinking and accept, that Linux DOES NOT FRAGMENT FILES.

Shorty943.

fudam 01-08-2007 09:27 PM

It seems like HGeneAnthony is asking a good, technical question. In the end, whether it's linux, windows, or os/2 a partition is still a bunch of clusters and there's got to be some methodology to how you store data.

I wouldn't expect "Just stop thinking and accept" as a reply on a Linux forum. Linux is all about thinking, and not at all about accepting...

Sepero 01-08-2007 09:42 PM

Run fsck on your filesystem. After it is finished, it will say X.X% non-contigious files. That percentage is how much fragmentation you have on your system.

Yes, as space goes down, fragmentation can tend to go up. I have roughly 40 to 0 Megs available at given time on one of my systems. Last time I checked it, I think it was between 5-10% fragmentation. (That is really HIGH for Linux!)

HGeneAnthony 01-09-2007 11:36 PM

Reply
 
Really surprised to get a shut up and accept it without question answer on a Linux forum. Sepero made a good point. He on occasions has had between 5 to 10% fragmentation on his system. So shorty943 what's your response to this?

reddazz 01-10-2007 12:37 AM

Fragmentation can happen on Linux filesystems, but only if the disk is almost full. There are many articles on the net that discuss this issues, so doing a search on Google might be helpful.

eyebrowsoffire 01-10-2007 02:39 AM

I don't really know very much about this, but I thought I'd put in my two cents:

I read somewhere that even when linux filesystems get fragmented that it has very little or no effect on performance.

Sepero 01-10-2007 03:20 AM

Quote:

Originally Posted by HGeneAnthony
Really surprised to get a shut up and accept it without question answer on a Linux forum.

Please don't be. There are members that help more, and members that help less in every community. The Linux community is no exception.

I posted my fragmentatin to prove a point. IMHO, even on a highly congested system with 5-10% fragmentation, it is not going to have much effect at all. It is not enough to worry about. Linux takes care of fragmentation so you don't have to.

On my desktop system, I've never seen it even reach 2%.

Daws 01-10-2007 05:06 AM

Hmmm. When I was at school contiguous meant touching or adjacent to. Don't quote me on this but I believe that non-contiguous files do not affect performance (the file is still at one location).

****aaaabbbbcccc****

here a, b and c are contiguous.

If you delete b:

****aaaa****cccc****

a and c are non-contiguous, but not fragmented. It is the free space that is fragmented. This will inevitably lead to file fragmentation as the disk fills up though.

--

I'm not entirely sure how it all works but I think in the windows world if I write an 8* file, d:

ddddaaaaddddcccc****

this would happen. File d is now fragmented.

I think in linux either c is moved before writing

****aaaaccccdddddddd

or it is written fragmented as in windows and fixed later on.

It does entirely depend on the filesystem in use however. I quite like XFS, but I have no idea how it deals with fragmentation.

shorty943 01-10-2007 07:09 AM

Quote:

Originally Posted by HGeneAnthony
Really surprised to get a shut up and accept it without question answer on a Linux forum. Sepero made a good point. He on occasions has had between 5 to 10% fragmentation on his system. So shorty943 what's your response to this?

1 I did not say shut up. Period. My statement was stop thinking the windows way. Maybe my system does not get that choked up that it begins to fragment.

2 I regret my frustration showing, sorry.

3 So. Happy?

A thank you to sepero for the understanding mind.


Shorty.

jerril 01-10-2007 08:04 AM

When you get to the point where a Linux partition is fragmenting, a windows system would become almost unusable, there would be no room for virtual memory let alone a defrag run.

I haven't filled up a drive in a long time; most of my files are stored on one huge drive. From what I remember, you don't want to let any drive on any system get too full, ever.

jer

HGeneAnthony 01-10-2007 12:10 PM

Reply
 
Thanks for the replies although it doesn't really answer my question. Now if Linux reorganizes the disk on the fly it would eliminate fragmentation once the free space is over 20% again, however I never got an answer on whether this was the case. I'm just trying to understand why it never gets fragmented for when I talk to my Windows friends rather than I'm concerned about fragmentation.

nx5000 01-10-2007 12:28 PM

OK once again just for fun
"Stop thinking like windows"
There is not only ONE filesystem for linux. There is a common Filesystem mechanism called VFS but it doesn't do the real allocation, its just a pointer array.

So which filesystem?

Because there are definetly some linux filesystems that suffer from fragmentation, the most known being jffs which is used a lot in embeded environment.

shorty943 01-10-2007 05:56 PM

Quote:

Originally Posted by nx5000
OK once again just for fun
"Stop thinking like windows"
There is not only ONE filesystem for linux. There is a common Filesystem mechanism called VFS but it doesn't do the real allocation, its just a pointer array.

So which filesystem?

Because there are definetly some linux filesystems that suffer from fragmentation, the most known being jffs which is used a lot in embeded environment.


A very big thank you nx5000, for your support. Just for the fun of it. Not funny how some folk are difficult to inform.

There are now 2 people in this forum, who have found a new friend in the world at large.

Shorty943.

Sepero 01-10-2007 07:06 PM

HGeneAnthony, the problem is that you haven't clearly stated your question. I will attempt to clearify it, then answer it.

"Why does Linux not become badly fragmented like Microsoft systems?"
Because Linux places the files on the disk intelligently, instead of simply placing them in the next free spot. It leaves some 'padding' at the ends of many files, incase you write more to that file later. This allows the files remain in one piece.

Matir 01-11-2007 12:45 PM

Each filesystem type uses its own file-placement algorithm. FAT had a VERY simple algorithm: fill each hole in the partition as it went along. This, unfortunately, led to high fragmentation. NTFS does a little better, but still has fragmentation issues.

Linux filesystems reduce fragmentation. They begin by overallocating (when space is available) and reserving a few blocks past the end of a file for future expansion. They also don't usually allocate blocks on disk when a file is opened for writing, but rather when it is closed and the file's size is known. (Exceptions: if the disk is mounted with the 'sync' option or if the sync() system call is used to force flushing buffers to disk)

Some of the filesystems will reallocate fragmented files on their next use if space is available, but not all, and not always. Thus, if fragmentation has occured, it will sometimes remain behind.

If you don't run your disk at >90% full, I would not have any concern about fragmentation.

Sepero 01-11-2007 06:48 PM

After searching sourceforge.net and freshmeat.net, I found the 'shake' defragmenter. Of Linux defragmenters, it appears to be the only one that's maintained.
http://freshmeat.net/redir/shake/649...homepage/shake

tomtechguy 01-12-2007 11:07 PM

A quick Googleing on ext3 and fragmentation.

http://www.itworld.com/Comp/3380/nls...929/index.html


All times are GMT -5. The time now is 08:11 AM.