LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-15-2003, 09:31 PM   #1
FearPasion710
Member
 
Registered: Jul 2003
Distribution: Gaytoo...
Posts: 96

Rep: Reputation: 15
Question How Can i Defrag Linux???


Okay My Question is this one. Do you guys remember in windows that when it got slugish or just to danm slow we used to defragment the HardDrive?

Well my question goes for linux? how can i accomplish this in linux?

and no linux is not running slow at all! Mandrake has been installed for 8 months now and no problem with slowness due to disk fragmentation....

But i have a large collection of files in this system and to tell you the truth a couple of 100 files are added regurlaly this is because it acts like a server for my home network.

Well Can Someone Please help me with this!

My Filesystems are:

/dev/hda1--ext3--36.4Gb--/--31.1GB--14.6%
/dev/hdb1--reiserfs--74.5Gb--/media--12.4GB--10.8%

thank you!!

 
Old 09-15-2003, 09:40 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
well i guess you can try defrag
 
Old 09-15-2003, 10:08 PM   #3
contrasutra
LQ Guru
 
Registered: Mar 2003
Location: New Jersey
Distribution: Arch Linux
Posts: 1,445

Rep: Reputation: 47
Code:
fsck
is a "scandisk" and "Defrag" tool.

DONT RUN IT ON A MOUNTED PARTITION.


But long story short, you don't need to defrag, linux partitions dont fragment.
 
Old 09-15-2003, 10:17 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
You basically answered your own question. Your system been running for 8 months with no sluggishness, running smoothly. That should tell you right now that linux does not need to defragmented.

You need to get our of your M$ mind and start using your *nix mind. Using M$ for so long, its just a state of mind that is created that makes you think your system is going to work better if you defragment it, which isn't the case ever in Linux.

Regards.
 
Old 09-15-2003, 10:54 PM   #5
FearPasion710
Member
 
Registered: Jul 2003
Distribution: Gaytoo...
Posts: 96

Original Poster
Rep: Reputation: 15
Cool THANKS

Thank you i really appreciate all the effort you guys put into answering this questions! Thanks
 
Old 09-15-2003, 11:02 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Depends on who you ask...

I asked this question many moons ago, was told "you don't need to defrag Linux", and I was given a link to a site with an explanation. The crux of the argument was that Linux is a multi-user operating system, and that nobody can predict what requests multiple users will make at any given time, thereby negating any benefit from having a defragmented drive. I agree, but there's an underlying assumption that multiple users will be on the machine at the same time. That's not the case with my computer at home. Daemons might be considered other users perhaps, but for the most part, my drive remains quiet unless I open a new application, file, or something along those lines.

In the same thread, someone said that fsck will tell you how fragmented your drive is (I think it reports it as a (non-)contiguous percentage). That user was reporting something like 30% fragmentation.

It depends on what you're using the computer for. If you plan to run a server of any kind, then you cannot anticipate read/write requests from users that are logged in, meaning that fragmentation is not a concern. If you are the only user on the machine, defragmenting a drive can help by reducing the number of jumps the drive read/write heads have to make to get all your data.

Disclaimer: I'm not an expert on the internal workings of filesystems, but unless there's some sort of "cleanup" overhead associated with a filesystem, then a drive will become fragmented over time. If the cleanup overhead does exist, then essentially the filesystem defragments itself in small bits every so often.
 
Old 09-20-2003, 07:06 PM   #7
voltron1011
Member
 
Registered: Aug 2003
Location: Tucson, AZ
Distribution: Red Hat 8
Posts: 62

Rep: Reputation: 15
Swap files create a lot of fragmenting. On MS crap, the swap files (virtual memory) are all on that same happy C drive. When things get cluttered up, it just moves the swap file to the next free area on the harddrive. Correct me if I'm wrong, but Linux has it's own PARTITION for swap files. This means that you don't ever have to worry about those annoying little chunks of data being spread all over your harddrive. Although the swap partition will get cluttered, it is no problem because it is acting much like RAM (Random Access Memory) in which it too gets CONTINUOUSLY fragmented.
 
Old 09-20-2003, 08:52 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I don't know how swap files are implemented in Windows. I'd consider it bad design to allow the swap file to grow and shrink. That would definitely lead to more fragmentation. If logic were used, Windows would probably reserve X amount of space on the drive as a single swap "file" and simply move contents in and out of it as necessary. Again, that's speculation, because I don't know the details.

You can get fragmentation without swap files though. A hard drive stores data in blocks/sectors. Let's say you save three files:
FileA: 4 blocks
FileB: 2 block
FileC: 5 blocks

Everything looks good because the data is stored in consecutive blocks on the drive. Now lets say you don't need FileB and delete it. That leaves a two-block "hole" in the sequence of blocks. Now let's say you create a new file, but it requires 3 blocks to save. Where does it go? After FileC? If that's the case, then you'll never be able to fill the hole created when you deleted FileB. You could fit 1 two-block file there or 2 one-block files, but you would never be able to fit anything bigger than that in the same space. That means at some point in the future, you would have to use a utility to consolidate free space; one of the responsibilities of a defragmenter.

Another option would be to split the file: use the first two blocks occupied by FileB, and indicate that the file continues in the first block after FileC. That way, you use space more efficiently, but you cause delays when the read/write heads of the disk have to jump one (or more) times to read the entire contents of the drive. Again, a defragmenter would be required to rearrange things so the drive's heads only have to seek the data once.

Another possible problem is if FileB grows to 3 (or more blocks). Again, where do you put the file? Do you move the whole thing after FileC (and create the same "hole" earlier), or split it?

Typically, blocks/sectors on a hard drive are 512 bytes in size. So it's rather easy to see how any file can expand or shrink in a manner like above.

Last edited by Dark_Helmet; 09-20-2003 at 08:56 PM.
 
Old 10-27-2003, 02:27 AM   #9
Y0jiMb0
Member
 
Registered: Jul 2003
Location: Valencia (Spain)
Distribution: slackware 11, FEDORA CORE 4, RHEL3, Gentoo...
Posts: 361

Rep: Reputation: 30
http://www.mail-archive.com/expert@l.../msg17753.html
 
Old 10-29-2003, 04:45 PM   #10
tycho102
LQ Newbie
 
Registered: Oct 2003
Distribution: Mandrake 9.1
Posts: 6

Rep: Reputation: 0
Quote:
Originally posted by DrOzz
well i guess you can try defrag
Wholey Muther! That link is from 1998!

I'm scared to run it.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
defrag on Linux ashley75 Linux - General 27 02-05-2009 04:21 PM
Defrag in Linux? fedivh Linux - General 4 02-09-2004 04:02 PM
Does Linux have defrag... kjp_72 Linux - Software 7 04-19-2003 12:57 PM
Defrag in Linux? orange400 Linux - General 7 03-15-2003 02:32 AM
Defrag in Linux? glitch Linux - Newbie 2 09-02-2002 06:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:02 PM.

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
Open Source Consulting | Domain Registration