Linux - GeneralThis 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.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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.
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.