Disk optimization is a process in which the physical locations of files on a volume are "streamlined." Files and metadata are re-arranged in order to improve data access times and minimize time moving a hard drive's head.
Files can become "fragmented" over time as they are changed and saved and as the volume is filled, with different parts of a single file stored in different locations on a volume. The process of collecting file fragments and putting them "back together" is known as optimization. However, if a failure occurs during optimization, such as power loss, files could become damaged and need to be restored from a backup copy.
Do you need to optimize?
You probably won't need to optimize at all if you use Mac OS X. Here's why:
1 - Hard disk capacity is generally much greater now than a few years ago. With more free space available, the file system doesn't need to fill up every "nook and cranny." Mac OS Extended formatting (HFS Plus) avoids reusing space from deleted files as much as possible, to avoid prematurely filling small areas of recently-freed space.
2 - Mac OS X 10.2 and later includes delayed allocation for Mac OS X Extended-formatted volumes. This allows a number of small allocations to be combined into a single large allocation in one area of the disk.
3 - Fragmentation was often caused by continually appending data to existing files, especially with resource forks. With faster hard drives and better caching, as well as the new application packaging format, many applications simply rewrite the entire file each time. Mac OS X 10.3 Panther can also automatically defragment such slow-growing files. This process is sometimes known as "Hot-File-Adaptive-Clustering."
4 - Aggressive read-ahead and write-behind caching means that minor fragmentation has less effect on perceived system performance.
For these reasons, there is little benefit to defragmenting.
Note:Mac OS X systems use hundreds of thousands of small files, many of which are rarely accessed. Optimizing them can be a major effort for very little practical gain. There is also a chance that one of the files placed in the "hot band" for rapid reads during system startup might be moved during defragmentation, which would decrease performance.
If you think you might need to defragment:
1 - Try restarting first. It might help, and it's easy to do.
2 - If your disks are almost full, and you often modify or create large files (such as editing video, but see the Tip below if you use iMovie and Mac OS X 10.3), there's a chance the disks could be fragmented. In this case, you might benefit from defragmentation, which can be performed with some third-party disk utilities.
3 - Another option is to back up your important files, erase the hard disk, then reinstall Mac OS X and your backed up files.
Tip: If you use iMovie with Mac OS X 10.3 Panther, and FileVault is enabled, performance issues can occur if your project is located in your encrypted home folder (including the desktop). See iMovie: Using FileVault Can Affect Performance.