LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-02-2004, 03:17 AM   #1
sirpelidor
Member
 
Registered: Oct 2003
Location: Madison
Distribution: mdk 8.2, 9.0, 9.2, slack 9.1
Posts: 403

Rep: Reputation: 30
filesystem: linux needs to "defragment"?


as we all knows, M$ ramdomly throw files in our hardisk. that's why once a while, we need to run defragment to pull all the files together. so cpu have a little less load when access files.

what about linux? we use tree system, everything is under /
and the rest of 'em can be either under /, or under diff partition (for example /home on diff partition) but still, how does linux store its file? does it need to be "defragment" or only broken toy needs to do that?

thanks
 
Old 01-02-2004, 06:10 AM   #2
CrazyPilot
Member
 
Registered: Jan 2004
Location: Somewhere...
Distribution: Fedora Core 4, Slackware 10.1
Posts: 61

Rep: Reputation: 15
Good question, I look forward to a response.
 
Old 01-02-2004, 06:29 AM   #3
Baldrick65
Member
 
Registered: Aug 2003
Location: Dunedin NZ
Distribution: Mint 13 Cinnamon
Posts: 653

Rep: Reputation: 31
I stumbled across this in my travels somewhere. It explains why you don't need to defragment Linux file systems.
Quote:
Basically Linux has a different way of handling drivespace file allocation. Linux splits up the drivespace into "superblocks" and pretty much tries to stick the whole of a file into one contiguous section of the drive. M$ doesn't do that. M$ just sticks as much of the file as it can into the first open spot on the drive, no matter how much or how little of the file it can fit in there and then moves on and does so again, until the file is completely written to the drive. This has a tendancy to really fragment files. Also, Linux doesn't try to keep all the files as close to the start of the drive the way M$ does. Linux splits up the drive into "superblocks" and has multiple indices showing where everything is located.
HTH
Baldrick
 
Old 01-02-2004, 07:09 AM   #4
CrazyPilot
Member
 
Registered: Jan 2004
Location: Somewhere...
Distribution: Fedora Core 4, Slackware 10.1
Posts: 61

Rep: Reputation: 15
thank you

that is very interesting
 
Old 01-02-2004, 08:30 AM   #5
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
In addition to what was quoted by Baldrick65 (which basically refers to the ext2fs file system), Linux nowadays comes with support for several journaling file systems - ext3fs, ReiserFS, XFS, JFS, and some commercial ones too I believe. These add more functionality by keeping a journal of recent changes (writes) and changes waiting to be done. The journal is always reviewed on boot, so if you are transferring files when the system goes down (power interrupt or whatever) the journaling fs will notice that the journal is inconsistent on the next boot. It will check what has been done and what was supposed to have been done when the system went down, it corrects those errors that might have occured and everything is smooth sailing again. Very neat, and it's a feature from the database world in case you wanted to know.

Other file systems, like FAT32 (NTFS is *sort* of a journaling fs) and ext2fs, will experience corruption that can lead to unusable corrupted data if a transfer is interrupted. That's why you get the file system checks on boot when the computer has crashed (fsck - for file system check - on Linux, and chkdsk on Windows).

Usually, fsck is sheduled to run on ext2fs partitions every now and then using the cron service, to make sure they're fine.

You can easily convert ext2fs partitions to ext3fs by running tune2fs -j <partition> - I recommend this if you're still using ext2fs. If you do that you will want to update your /etc/fstab to indicate the partition uses ext3fs too.

More not-so-useful trivia: ext2fs is the updated version of Linux' original own file system - the extended file system, extfs. ext2fs is meant to be pronounced "second extended file system", so ext3fs is pronounced (drum roll, please) "third extended".

Håkan
 
Old 01-02-2004, 08:59 AM   #6
rgerhards
Member
 
Registered: Sep 2003
Distribution: Fedora/Debian
Posts: 50

Rep: Reputation: 15
Very interesting read. I am a newbie, so I may be totally wrong. But I try to understand things. If I look at the described algo, I have the impression that it is very well possible that on a drive with many small files it may be possible that some fragmentation occurs (especially if the disk is relatively full). An example I can think of is a development machine. Even though I see that the described algo will try to find a big enough block, it may run into issues and need for fragmentation when it doesn't - at least it looks that way to me. Out of basic understanding of disk layout, I think a file system can not totally prevent fragmentation without some maintenance runs that consolidate file fragments when more bigger chunks are available so that a file split across multiple disk regions can now fit into a single one.

Am I missing something?
 
Old 01-02-2004, 09:15 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Quote:
Originally posted by CrazyPilot
Good question, I look forward to a response.
a good question that has been asked probably a hundred times on this site alone, a search never hurts....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Enabling local filesystem quotas" - boot failure Boby Linux - Software 1 01-22-2005 06:21 PM
USB stick, "losing space" - filesystem inconsistensies? iskrem Linux - Hardware 1 11-26-2004 07:01 PM
Get this error message: "filesystem is needed by glibc-2.3.2-92" When installing??? Qwirt Linux - Software 1 07-28-2004 07:00 AM
RH9 "remounting root filesystem in read-write mode" ChrisHax Linux - Newbie 3 07-23-2004 10:54 PM
dump + restore to backup linux ; "Couldn't find matching filesystem: LABEL=/" on boot markus1982 Linux - General 4 09-21-2002 02:16 PM


All times are GMT -5. The time now is 10:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration