First the Manual.
PS3™ | Settings
Settings > System Settings > Restore Default Settings
Settings > System Settings > Restore PS3 System
A 'Quick Format' will simply erase everything from the Hard Drive (except the System Files). A 'Full Format' will do a Quick Format and scan the hard drive for errors and fix them automatically. A 'Full Format' is recommended. It may take anywhere between 2 and 32 hours!
Not documented in the Manual: PS3 - How to do a factory / hard reset
PS3 – How to do a factory / hard reset - Tech-Recipes
(You may hear only one beep when the power button is kept pressed on the newer systems)
Do at your own risk.