While there are a number of utilities that will perform drive defragmentation and optimization, this option is usually included as a small side-feature along with a slew of other drive-related functions. Conversely, iDefrag is a small utility with the single purpose of running drive defragmentation and optimization, and does this job quite well. Over the years it has become a reputable and complete option for people wanting to defragment and optimize their hard drives.
The program features a simple interface that shows a block-by-block layout of files on the drive (very common for optimization and defragmentation programs), along with statistics sections for the individual files and the volumes as a whole which give a large amount of information despite their simplicity.
To defragment or optimize a drive, just select it in the "Volumes" tray, select the optimization algorithm, and click the green "Go" button. If the button is red, you will not be able to use the selected algorithm on the drive. This is usually because you have selected to use something besides "Quick" defragmentation on the boot drive. The available algorithms are as follows:
Compact -- Moves files to the beginning of the volume without organizing them so you may repartition or resize the drive.
Metadata -- This is the basic defragmentation scheme, which also optimizes the drive's hot zone and index files.
Quick -- This does a swift defragmentation of the drive on standard files, as a quick clean-up without touching system files, multi-linked files, or any others that may require special attention.
Optimize -- This is where iDefrag organizes files based on file type (class sets) so they may more easily be accessed in various tasks. Examples of class sets are "Startup Files", "Kernel Files", "User files", "Journal Files", and "Volume Header" files.
Full Defrag -- This runs both the "Metadata" and "Optimize" routines for a full defragmentation and optimization of the hard drive.
While at its basics iDefrag performs optimization and defragmentation, it supports a few other features that may be useful to people who regularly defragment their volumes.
Scripting support -- Because of its support for Applescript and Automator, iDefrag can easily be configured to run in a variety of scripts and schedules.
Boot drive management -- With iDefrag, you can defragment the boot drive; however, you are limited to using the "Quick" algorithm which only targets files that are not in use.
Hot zone management -- In order to decrease loading times, OS X will move frequently used files to a location on the hard drive that is quickly accessed by the drive heads (the "Hot Zone"). iDefrag will manage these locations in its optimization algorithms to ensure the system can make full use of them.
Monitoring and safeguards -- As with any well-made disk utility, iDefrag includes a variety of checks to ensure the files it is handling are not lost or corrupted in the event of an interruption during optimization or defragmentation. These are customizable in the program's preferences, and you can enable or disable options to verify writes, monitor disk temperatures, and customize the algorithms to enable or disable more risky features. Despite this, before running any disk utility you should be sure to have a full backup.
Filesystems -- iDefrag is an HFS-only utility, which means it will only support HFS, HFS+, case sensitive HFS, and Journaled HFS volumes. It will not work on FAT, NTFS (with third-party write support), or other formats.
While disk defragmentation and optimization are useful and in some situations may show a significant speed increase, there is a significant amount of debate around whether or not people should bother. Not only are there built-in fragmentation safeguards that may decrease the need of third-party utilities, but there are also data safety concerns with running optimization routines on drives.
Is defragmentation needed?
On one hand, having files intact on a disk is always better than fragmented and scattered files. However, keeping them this way requires regular use of defragmentation routines that can degrade performance if run continuously, and can also increase the chance of error as files are moved around the hard drive. Therefore, on the other hand it may not be worth either the time or any potential risk to regularly run defragmentation.
Apple's philosophy for hard drive optimization and defragmentation is explained in this knowledgebase article and is basically that they do not recommend it unless it is absolutely needed (I tend to agree).
To combat the majority of file fragmentation, OS X already has robust built-in anti-fragmentation technologies that prevent fragmentation of files on creation and use; however, they are only applied to files that are under 20MB in size. Because of this, defragmentation will provide the most benefit to those who regularly manage a large number of files that are over 20MB in size, but it will also help for those who have nearly full drives that are regularly used (e.g. Time Machine volumes).
Is optimization needed?
When you write a file to disk, the system will place it at the location that is easiest to access, and does not bother keeping it organized with others based on file type or task. The only organization the system does is maintain a hot zone where it keeps a relatively higher performing section of the drive free for placing frequently accessed documents.
Because of this, drive heads may need to move all over the disk when performing tasks, not because individual files are fragmented but because individual files required for the specific task at hand may be scattered. Optimizing a disk groups these files together so similar resources can be accessed as swiftly as possible.
As with defragmentation, optimization benefits will depend on the drive's uses. In my experiences the greatest benefit of optimizing a hard drive is that startup times can be noticeably reduced by keeping all the system files together on the drive. Application launch times and file loading may also be decreased; however, because regular use will move files around the disk, the benefits of optimization will slowly degrade until you run it again.
Whenever you access a file you increase the risk of some fault resulting in file corruption; defragmentation of a drive subjects all the files on disk not only to being read, but also to being copied, rearranged, and deleted. These tasks increase the risk of corruption, and iDefrag will run all of them on every file in the drive. However, iDefrag is coded with numerous checks to prevent errors such as overwriting of files, or data loss in the event of a power outage or cancellation. It also actively scans the drive for bad blocks and other integrity errors during its optimization.
Regardless of the safety measures taken by any developer, your safest bet is always to have a full backup of your drives, so be sure you have Time Machine or other backup system fully updated before running iDefrag. Keep in mind that running disk optimization and defragmentation uses the drive at full speed, which can cause some problems with heat if drives are not well ventilated (though iDefrag monitors drive temperature during defragmentation).
In iDefrag's FAQ, there is specific warning against using the program with PowerMac G5 computers that have Western Digital hard drives, since intensive use of these drives can cause them to stop responding in the system. Data loss will not occur, but the system may need to be restarted.
So when should I run iDefrag?
If your computer is taking time to boot, open large files and applications, or your hard drive is making an inordinate amount of noise, I suggest doing the following steps:
Restart the computer -- many times slow systems are from programs and the system using up too much RAM and other resources. If quitting the programs does not free up memory properly (either from memory leaks or other errors), restarting the computer should do the trick.
Check drive space -- full hard drives can result in fragmented virtual memory and data files, and low space for virtual memory. This can cause programs to run slowly and access the hard drive frequently while it manages the limited virtual memory resources.
Run Disk Utility -- use a disk utility program to check the drive's structure, integrity, and SMART status to ensure the hardware and formatting is stable.
Run a defragmenter like iDefrag -- first defragment files, and then optimize them for an extra boost in drive efficiency.
Notice the defragmenter is the last of what should be checked for open iDefrag and check to see if the drive is heavily fragmented (shown in the "Statistics" section). This is because even if defragmentation will benefit you, many times other problems are what is causing computer slow-downs and should be addressed first. Despite this, as part of any troubleshooting arsenal I always recommend that people have a good defragmentation utility, and iDefrag is definitely up there with the best.
You can get iDefrag (which has been recently updated to beta version 2.0.0b2, though version 1.7.2 is the latest official release) from the Coriolis Systems website: http://www.coriolis-systems.com/iDefrag.php