To help troubleshoot problems in OS X, Apple supports several alternative boot modes, the most common of which is safe mode. There's also a verbose mode that displays what background processes are being loaded, and a single-user mode to avoid user accounts and the OS X graphical interface. While these various modes can be useful, there are times that a system gets stuck loading them and won't boot normally.
These modes are triggered by a boot argument that is passed to the OS X kernel, which can be done in one of two ways. The first is to use the keyboard to temporarily set these boot arguments by holding Command-V (for verbose mode) or Command-S (for single-user mode) immediately after hearing the system's boot chimes. The second method is to use the system's PRAM variables, which are hardware settings that are used before the operating system loads. One of these settings is a boot arguments option that is passed to the OS kernel, similar to when keyboard hot keys are used. These can be set for verbose and safe modes using the following commands in the OS X Terminal:
sudo nvram boot-args="-v"
sudo nvram boot-args="-s"
In addition to boot argument errors, if your system is constantly booting to one of these modes, you may see some other issues, including volume levels being reset at startup and the system taking a little longer to locate the boot drive. This could be because these variables are also stored in the system's PRAM; if there is some corruption in the PRAM, the system may not be storing proper values for volume and the preferred boot drive.
Since these behaviors primarily revolve around the PRAM, if you are experiencing them, then the best solution is to reset the PRAM on your Mac. To do this, reboot the system and immediately hold down the Option-Command-P-R keys after hearing the boot chimes. With these keys held, let the system automatically reset and create the boot chimes again (they may sound at a different volume), and then release the keys and allow the system to boot normally.
You can also try directly clearing any boot argument variables in the PRAM by running the following command in the OS X Terminal (including the single-user mode command line):
sudo nvram -d boot-args
After performing this reset, the system may have some small differences in behavior such as faster or slower mouse speeds, volume level changes, and may revert to a different boot volume if you have multiple OS X installations on your computer; however, these should be automatically set by stored settings in your OS, or by going to the system preferences and making the necessary changes to these settings.
For some systems, the computer will boot to single user mode if there are problems with the file-system structure on the hard drive, so if the problem persists after a PRAM reset, then try booting to safe mode (hold Shift after hearing the boot chimes on startup) to see if the system loads in that mode. Safe mode runs a disk repair routine that should ensure that the file-system structure is intact for proper use, and should help clear this problem. You can also perform this step manually from within single-user mode by running the following three commands:
mount -uw /
fsck -f /
In addition to using fsck, you can check the drive with Apple's Disk Utility loaded from the OS X installation disc (in the Utilities menu that appears when the installer loads), or from the OS X Tools menu in the Lion or Mountain Lion recovery HD partition.
If the file system shows an error that cannot be fixed when checking with these utilities, then your best bet is to either try formatting the drive and reinstalling OS X (or restoring from a recent backup), or replacing the drive altogether (especially if file-system errors continually crop up).