If your computer originally came with Lion or later pre-installed, then try this:
Install Lion Through Yosemite on a New HDD/SDD
- Restart the computer and after the chime press and hold down the COMMAND-OPTION- R keys until a globe appears. Wait patiently - 5-15 minutes - until the Utility Menu appears.
- Select Disk Utility from the Utility Menu and click on the Continue button.
- After Disk Utility loads select the drive (usually, this is the out-dented entry with the mfgr.'s ID and size) from the side list. Click on the Partition tab in Disk Utility’s main window.
- Under the Volume Scheme heading set the number of partitions to one volume. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the Format type to Mac OS Extended (Journaled.) Click on the Partition button and wait for the process to finish. Quit Disk Utility and return to the Utility Menu.
- Select Reinstall OS X from the Utility Menu and click on the Install button.
If your computer came with Snow Leopard or earlier pre-installed, then you must do this:
Snow Leopard Erase and Install
- Insert Snow Leopard DVD into the optical drive and restart the computer.
- Immediately upon hearing the chime hold down the C key.
- Release the key when the Apple logo appears and wait for the loading to finish.
- 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 Disk Utility loads select the out-dented disk entry from the side list (mfgr.'s ID and drive size.) Click on the Partition tab in the Disk Utility’s right window. Set the number of partitions to (1) from the drop down menu. Click on Options button and select GUID, click on OK, set the format type to MacOS Extended, Journaled. Finally, click on the Apply button.
- After formatting has finished quit Disk Utility. Continue with the OS X installation and follow the directions.
- When the installation has finished the computer will restart into the Setup Assistant. After you complete the Setup Assistant you will be running a fresh installation of Snow Leopard. Open Software Update and install the recommended updates.
- If you are planning to sell or give your computer away, then do the following: After you reformat your hard drive and reinstall Snow Leopard, the computer restarts to a Welcome screen. To leave the Mac in an OOTB (Out Of The Box) state, don't continue with the setup. Instead, press Command and Q keys to shut down the computer. The Setup Assistant will guide the new owner through the setup process after he/she turns on the computer.
- Download and install Mac OS X 10.6.8 Update Combo v1.1. if needed. It is not needed if you are selling or giving away the computer.
If you are unable to do either of the above due to reported errors then your drive is bad and must be replaced.