Defragging rarely accomplishes anything beneficial these days, drives are just too darned big. No justifiable reason to optimize.
Make a clone of your drive to an external FW drive using Carbon Copy Cloner but be sure to read how to do it properly. Reinstall the operating system using the Archive and Install option.
When you're done, use the Migration Assistant to bring over your stuff form the FW drive. Easy, just takes several hours.
This is my standard sigfile so do not take it personally: "For crying out loud, read the freakin' manual."