A failing hard drive can mean loss or corruption to important data or to applications and system software that can further destabilize the system. If your Mac regularly slows down or crashes, or if you get odd 'permissions denied' errors about the inability to access certain files you previously had access to, then your drive may be on its way out.
The first option for testing your drive is to check its SMART (Self-Monitoring, Analysis, and Reporting Technology) status, which is a series of built-in benchmarks and thresholds that the drive regularly monitors itself. If any of these are out of place, then the drive will flag it to the system when a SMART check is performed. This can be done at any time using Disk Utility by opening the program and selecting your drive device. Then, at the bottom of the window you will see a "SMART Status" with the results of the check. If this says anything other than "Verified," then you need to replace your drive.
Disk Utility is not the only option for checking the SMART status, as there are numerous third-party programs like SMART Utility (some of which are free), that may be an even more thorough SMART checker than Disk Utility.
If the SMART status checks out, then check the disk's formatting regularly with Disk Utility. If your first check shows formatting errors, boot to the Recovery HD partition by holding Command-R at startup, and then fix the drive. Follow this by checking the drive's formatting regularly (daily), to ensure that no more errors crop up. If they do, then this indicates the drive may be failing.
Finally, use a third-party utility like Drive Genius or Disk Tools Pro to check the drive's media with a surface scan. This will check for bad blocks and replace them with spare blocks, if necessary. If you do find bad blocks with a scan, then again repeat this scan the following day, after using your system, and continue to do so for a few more days. If bad blocks continue to appear, then this suggests the drive will likely need to be replaced.
For external drives, unfortunately, SMART status checking is not supported; however, you can still check its formatting and perform a surface scan.
In addition, for external drives you can troubleshoot any daisy chains and drive connections if the drive will not mount, or if it suddenly ejects, since improper daisy-chaining can lead to loss in power or data connection that can corrupt drive contents.
Questions? Comments? Have a fix? Be sure to check us out on Twitter.