LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How Can i Defrag Linux??? (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-defrag-linux-93224/)

FearPasion710 09-15-2003 09:31 PM

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 :rolleyes: 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!!

:D

DrOzz 09-15-2003 09:40 PM

well i guess you can try defrag :D

contrasutra 09-15-2003 10:08 PM

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.

trickykid 09-15-2003 10:17 PM

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.

FearPasion710 09-15-2003 10:54 PM

THANKS
 
Thank you i really appreciate all the effort you guys put into answering this questions! Thanks

Dark_Helmet 09-15-2003 11:02 PM

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.

voltron1011 09-20-2003 07:06 PM

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.

Dark_Helmet 09-20-2003 08:52 PM

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.

Y0jiMb0 10-27-2003 02:27 AM

http://www.mail-archive.com/expert@l.../msg17753.html

tycho102 10-29-2003 04:45 PM

Quote:

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

I'm scared to run it.


All times are GMT -5. The time now is 11:50 PM.