« // »

Defragmenting

There are many people out there that say that *nix and Mac file systems don’t fragment — only Windows does.

They’re dead wrong.

[I know I’ve said this before, but it’s worth saying again]

All three file systems (and in Windows we’re talking about NTFS, not FAT) derive from the same basic file system organization, and all three have pretty much the same characteristics (there are differences, but those really have nothing to do with the likelihood of fragmentation).

Fragmentation is just a by-product of the way a file system works.  The file system must make decisions about how to lay files down on the disk, and since it doesn’t have a crystal ball it cannot see the future.  Thus is a file is pinned between two other files and it must grow, the file would either need to be moved (creating an empty spot of a maximum size) or extended in another area (thus being fragmented).

There are various schemes for handling file allocations, but most of them rely on an application that is creating the file giving the operating system (and thus file system) sufficient information on the files maximum size and hints as to whether it is temporary, may grow, etc.

Given that file systems will fragment, the need for defragmentation is real.  Windows recognizes this (mainly because Windows used to use a FAT file system where fragmentation caused severe performance issues).

If you have a *nix or Mac based system, I’m sure you can locate a reasonably good defragmenter (not every one is in denial about the need for periodically defragmenting the system).  If you have  Windows based system you already have a reasonably good defragmenter that came with the systems (a “lite” version of Executive Systems Diskeeper, which now just goes by the name of Diskeeper Corporation).  You can, of course, purchase a number of commercial products, like the full blown Diskeeper, O&O Defrag (my personal favorite), or download a host of free or inexpensive products.

The key to defragmenting your system is knowing when you should invest the time (and wear on your disks).  The most accurate answer would be when system fragmentation reaches a point where it adversely effects performance.  That seems a little vague, but most of the defragmentation tools actually will do an analysis and advise you if they should be run.  Some of them have active defragmentation (but like the file system, they don’t have a crystal ball, and will often cost performance, not enhance it — so I would just say no to active defragmentation).

A good rule of thumb is that right after you install you system, or any time you install major updates or service packs you should defragment your system.  It’s a good idea to clean off temporary files (like your browser cache, etc) before you defragment.  And you might even want to clean off old restore points (if you have them enabled).

There’s certainly no reason to defragment your system daily or weekly; but an occasional night of running your defragmenter of choice will likely decrease boot time and increase overall system performance.

One other little tid-bit — remove your paging file before defragmenting; then after you’re finished, create a new paging file of a fixed size (ie set the minimum and maximum to the same thing).  That way you have a nicely defragmented paging file that will not cause fragmentation or fragment itself (leading to better system performance).  Of course, if your system has enough memory to run without a paging file, you don’t need one at all.

Originally posted 2010-02-21 01:00:20.

« // »