Firstly, defragmentation is not necessary. Secondly, there is no program that can safely defragment a drive. I would not recommend defragmentation. But if you can't live another day until you do, then here's the safest and fastest way:
Cheap and Easy Defragmentation
You will have to backup your OS X partition to an external drive, boot from the external drive, use Disk Utility to repartition and reformat your hard drive back to a single volume, then restore your backup to the internal hard drive. You will use Carbon Copy Cloner to create the backup and to restore it.
1. Get an empty external hard drive and clone your internal drive to the
external one.
2. Boot from the external hard drive.
3. Erase the internal hard drive.
4. Restore the external clone to the internal hard drive.
Clone the internal drive to the external drive
1. Open Carbon Copy Cloner.
2. Select the Source volume from the left side dropdown menu.
3. Select the Destination volume from the left side dropdown menu.
4. Be sure the Block Copy button is not depressed or is ghosted.
5. Click on the Clone button.
Destination means the external backup drive. Source means the internal startup drive.
Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears. Select the icon for the external drive and click on the upward pointing arrow button.
After startup do the following:
Erase internal hard drive
1. Open Disk Utility in your Utilities folder.
2. After DU loads select your internal hard drive (this is the entry with the
mfgr.'s ID and size) from the left side list. Note the SMART status of the
drive in DU's status area. If it does not say "Verified" then the drive is
failing or has failed and will need replacing. SMART info will not be
reported on external drives. Otherwise, click on the Partition tab in the
DU main window.
3. Under the Volume Scheme heading set the number of partitions from the
drop down menu to one. Set the format type to Mac OS Extended
(Journaled.) Click on the Options button, set the partition scheme to
GUID then click on the OK button. Click on the Partition button and wait
until the process has completed.
Restore the clone to the internal hard drive
1. Open Carbon Copy Cloner.
2. Select the Source volume from the left side dropdown menu.
3. Select the Destination volume from the left side dropdown menu.
4. Be sure the Block Copy button is not selected or is ghosted.
5. Click on the Clone button.
Destination means the internal hard drive. Source means the external startup drive.
Note that the Source and Destination drives are swapped for this last procedure.
But far better to do some system maintenance which is far less hazardous:
Things You Can Do To Keep Your Computer From Slowing Down
If your computer seems to be running slower here are some things you can do:
Boot into Safe Modethen repair your hard drive and permissions:
Repair the Hard Drive and Permissions Pre-Lion
Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
Repair the Hard Drive - Lion
Boot from your Lion Recovery HD. When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported, then click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu. Select Restart from the Apple menu.
Boot to the Recovery HD:
Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
Restart your computer normally and see if this has helped any. Next do some maintenance:
Suggestions for OS X Maintenance
For situations Disk Utility cannot handle the best third-party utility is Disk Warrior; DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.x is now Intel Mac compatible.
OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep. Dependence upon third-party utilities to run the periodic maintenance scripts was significantly reduced since Tiger. These utilities have limited or no functionality with Snow Leopard or Lion and should not be installed.
OS X automatically defragments files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive. As for virus protection there are few if any such animals affecting OS X. You can protect the computer easily using the freeware Open Source virus protection software ClamXAV. Personally I would avoid most commercial anti-virus software because of their potential for causing problems. For more about malware see Macintosh Virus Guide.
I would also recommend downloading a utility such as TinkerTool System, OnyX 2.4.3, or Cocktail 5.1.1 that you can use for periodic maintenance such as removing old log files and archives, clearing caches, etc.
For emergency repairs install the freeware utility Applejack. If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the command line. Note that AppleJack 1.5 is required for Leopard. AppleJack 1.6 is compatible with Snow Leopard. There is no confirmation that this version also works with Lion.
When you install any new system software or updates be sure to repair the hard drive and permissions beforehand.
Get an external Firewire drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
1. Carbon Copy Cloner
2. Data Backup
3. Deja Vu
4. SuperDuper!
5. SyncTwoFolders
6. Synk Pro
7. Synk Standard
8. Tri-Backup
Visit The XLab FAQs and read the FAQs on maintenance, optimization, virus protection, and backup and restore.
Additional suggestions will be found in Mac maintenance Quick Assist.
Referenced software can be found at CNet Downloads or MacUpdate.
Additional Hints
Be sure you have an adequate amount of RAM installed for the number of applications you run concurrently. Be sure you leave a minimum of 10% of the hard drive's capacity as free space.
Add more RAM. If your computer has less than 2 GBs of RAM and you are using OS X Leopard or later, then you can do with more RAM. Snow Leopard and Lion work much better with 4 GBs of RAM than their system minimums. The more concurrent applications you tend to use the more RAM you should have.
Always maintain at least 15 GBs or 10% of your hard drive's capacity as free space, whichever is greater. OS X is frequently accessing your hard drive, so providing adequate free space will keep things from slowing down.
Check for applications that may be hogging the CPU:
Open Activity Monitor in the Utilities folder. Select All Processes from the Processes dropdown menu. Click twice on the CPU% column header to display in descending order. If you find a process using a large amount of CPU time, then select the process and click on the Quit icon in the toolbar. Click on the Force Quit button to kill the process. See if that helps. Be sure to note the name of the runaway process so you can track down the cause of the problem.
Often this problem occurs because of a corrupted cache or preferences file or an attempt to write to a corrupted log file.