If your Mac is experiencing problems running, one step for determining the problem is to boot the system into Safe Mode, which is a limited environment that only loads Apple-provided software for basic functionality. To get into Safe Mode you simply restart your Mac with the Shift key held; however, in some cases this will not work and the computer may simply boot normally or experience a problem and hang without booting at all.
The inability to boot into Safe Mode may happen because the system is configured with encryption or other security settings that prevent booting to such modes, because of nuances with how wireless keyboards pass boot arguments to the system, or because of errors in the file system.
Some security settings in OS X may contribute to the inability to boot to Safe Mode. If you have Apple's FileVault disk encryption technology enabled, or if you have a firmware password set on your system, then the computer will not boot to Safe Mode. To enter Safe Mode, you must first disable these options. FileVault can be disabled in the Security system preferences using the FileVault tab, but the firmware password must be disabled using the Firmware Password utility that is available in the Utilities menu in the OS X installer (You can get to this in OS X Lion and later by holding Command-R at startup).
A second potential issue that prevents Safe Mode from working is if you have a wireless keyboard. While many instructions suggest that you hold the Shift key at startup to get to Safe Mode, the system's Bluetooth controllers will only activate after the startup chimes sound, so if the key is held before this, the key press will not be recognized. Instead, if you have a wireless keyboard be sure to press and hold the Shift key after the boot chimes sound.
In addition to the timing of the key press, be sure to check your keyboard's battery level and replace the batteries if they are low.
File system errors
A final issue that may prevent booting to Safe Mode is if there are problems with the boot drive's file system structure. The HFS+ format includes a several indexing databases that hold information on where files are on the disk, and various attributes about them. When you run a file system check with Disk Utility, you will see them listed as the Catalog file, the Extents file, and Extended Attributes file, among others.
When the system boots to Safe Mode it will show a gray progress bar that indicates various maintenance tasks are being run at startup. One of these tasks is a filesystem check on file systems structure using the tool "fsck_hfs," but if a problem occurs that prevents the tool from checking then it may hang and result in the system only loading to the gray screen with the Apple and a progress bar below it.
Unfortunately it is a bit difficult to see if this is the case when the system is only displaying a gray progress bar; however, you can force the system to show you what is going on by having it boot to both Safe and Verbose modes at the same time. To do so, open the Terminal utility and run the following command. In this command I've used "Safe-Verbose" mode, but you can replace the "v" with an "s" to tell it to use "Single User" mode instead (they should be equivalent for this purpose):
sudo nvram boot-args="-v -x"
With this command run, reboot the system and you will see it load into a text environment with the most recent events happening at the bottom and the history of events scrolling upward. The system should at some point load a routine called "fsck_hfs," so look for it (this should happen relatively quickly, and then pause on this process for a few seconds while it checks the file system structure files mentioned above). This process should only take a couple of minutes, but if it does not progress after an extended period of time, then it is not able to check the disk for errors and is hung up, which is the cause for the inability to boot to Safe Mode.
If this is the case, hold the power button to hard-reset the system, followed by holding the Command-Option-P-R keys at startup (immediately after the boot chimes) to have the system clear the PRAM so it will load normally instead of in Safe-Verbose mode (release these keys after the system automatically resets and sounds the boot chime again). Now the fix for the issue is a matter of clearing the problem with the filesystem structure. While sometimes third-party tools like DiskWarrior have been known to find and correct errors that Disk Utility cannot fix, an alternative approach is to simply reformat the hard drive.
First be sure you have a fully restorable backup of your system, which can be done by using Time Machine or by creating a file-level clone of your drive with a tool like Carbon Copy Cloner. Then boot to the OS X installer (the Recovery HD drive in OS X Lion or later) and use Disk Utility there to partition and format the drive. Select the drive device (above the volume names like "Macintosh HD") and choose "1 Partition" from the drop-down menu in the Partition tab that appears. Name the drive and apply the changes to format it, and then exit Disk Utility and proceed with restoring your backup to the drive.
After the system is back up and running on the freshly formatted drive you should be able to boot to Safe Mode again.