Data corruption and loss: causes and avoidance
At The X Lab, we are often asked the question as to what causes corrupted preferences files, data corruption, damaged files, data loss, or files to suddenly "go missing." This FAQ addresses these questions by discussing:
The information in this FAQ is derived from our book, Troubleshooting Mac® OS X.
Causes of data corruption and loss
Common causes of data corruption and loss include:
- Power outages or other power-related problems.
- Improper shutdowns, such as caused by power outages or performing a hard restart: pressing and holding the power button or, on Macs so equipped, the restart button.
- Hardware problems or failures, including hard drive failures, bad sectors, bad RAM, and the like.
- Failure to eject external hard drives and related storage devices before disconnecting them or powering them off.
- Bad programming, particularly if it results in either hard restarts or data that is saved incorrectly.
Any of these causes can result in a corrupted hard drive directory. A corrupted hard drive directory can cause files to apparently "go missing" and lead to further data loss or corruption, such files being overwritten with new data as a corrupted directory may no longer accurately reflect what disk space is free or available vs. the disk space that contains data. The term data is used here to mean both files you have created as well as application and operating system code.
Technologies such as File System Journaling have helped to reduce the potential for directory corruption due to power outages or hard restarts, but journaling is not foolproof. Likewise, while hard drives have become exceedingly reliable, they are still known to fail catastrophically with little or no warning.
If operating system files become corrupted, your Mac may not start up or experience recurring kernel panics when a corrupted kernel extension is used. In addition to the causes cited above, operating system files can be corrupted by failed Software Updates.
Accordingly, it is appropriate to implement certain strategies to minimize the risks of data corruption and loss.
Strategies for avoiding data corruption and loss
Strategies for avoiding data corruption and loss on your Mac are as follows:
- Implement a comprehensive Backup and Recovery Solution and use it regularly.
- Implementing a comprehensive Backup and Recovery solution and using is regularly is essential to ensure against data loss in the event of a hard drive failure or other problems. For advice on the backup and recovery solution we employ, see our "Backup and Recovery" FAQ. Using a personal computer without backup and recovery is like driving without auto insurance. Likewise, without a Backup and Recovery solution, you are accepting the risk of potentially losing all of your data at some point.
- Perform the small amount of regular maintenance required for Mac OS X.
- See our "Maintaining Mac OS X" FAQ: it covers the regular maintenance we recommend and dispels some common "maintenance myths." In particular, a regular check for hard drive directory corruption is important as directory corruption is akin to cancer: early detection and treatment are essential.
- If you use a desktop Mac, you need an Uninterruptible Power Supply (UPS).
- Power outages and other power problems surges, spikes, brownouts, and the like can not only cause data corruption but damage your hardware. The "Protecting Against Power Problems" chapter of our book, Troubleshooting Mac OS X, covers this topic including the selection of an appropriate UPS in depth. Do not simply walk into a store and buy the first UPS recommended by a clerk. You want a UPS whose features match both the power requirements of your computing setup and your requirements for uptime during a power failure.
- Eject external storage devices, such as FireWire® drives, before either disconnecting them or turning them off.
- Failure to do so can result in data corruption. In the most severe cases, this can result in the partition map of the drive being corrupted, meaning one has to resort to data recovery techniques in hope of recovering the data on the now-inaccessible drive.
- A corollary to this rule is that if you are using external hard drives that require mains power, these should also be powered through a UPS. A power failure in such a case is no different than powering-off the external drive prior to ejecting it. Likewise, if you use bus-powered external drives on a desktop computer, that computer should be powered through a UPS.
- Troubleshoot problems when they occur.
- If you regularly "solve" problems by performing a hard restart and then returning back to work without first troubleshooting the cause of the problem, you risk letting a small problem compound into a larger problem. At a minimum, after a hard restart your should:
- Our book also has an entire chapter on methods for troubleshooting "Freezes and Hangs" which lead to hard restarts.
- Do not install Mac OS X Updates on a malfunctioning Mac.
- Hoping that you will fix a problem by either installing a Mac OS X Update or reinstalling the Combo Update corresponding to the version of Mac OS X you are using, without first checking for other problems like directory corruption can make a bad problem worse. Before installing software updates, consider the advice in our "Installing Software Updates" FAQ. Taking the steps therein before installing an update often helps avert problems and gives you a fallback position in case trouble arises.
- Think twice before using FileVault®.
- While FileVault can provide strong security for the data in your Home folder, it is also an "all your eggs in one basket" solution: if bad sectors develop on the hard drive in the area occupied by your encrypted Home folder, you could lose all of the data therein without a backup.
- Unless you have a pressing need for the industrial-strength security provided by FileVault, there are other methods for selectively protecting only the data that needs strong encryption. This topic is covered in more depth in the "Security" and "FileVault" chapters of our book.
- If your data-security needs demand FileVault, you should backup your encrypted Home folder regularly, preferably daily. Like any hard drive or disk image, a Home folder protected by FileVault an encrypted, sparse disk image does not respond well to the causes of data corruption cited above. This is why it is essential to regularly backup your encrypted Home folder using a comprehensive Backup and Recovery solution.
- Think twice before implementing RAID.
- If you use a desktop Mac that permits one to install multiple hard drives within the computer, such as a Power Mac or a Mac Pro, RAID is often advocated as a strategy for avoiding data loss. Furthermore, some RAID configurations improve the performance of disk read and write operations.
- However, it is our opinion that, unless one is running a high-volume transaction server with a 99.999% "Five Nines" availability requirement, RAID is overkill. For example, unless you are running a bank, a brokerage, or a major e-commerce site, implementing RAID will involve spending both time and money that could be applied elsewhere by the average user of Mac OS X.
- While RAID may be high on the "geek chic" scale, it is low on the "average user" practicality scale and very high on the "troubleshooting complexity" scale should problems arise. The difficulties that can arise in troubleshooting and solving RAID problems have led us to conclude that the average user is better served by implementing a comprehensive Backup and Recovery solution and using it regularly instead of implementing RAID.
- Do not "test-drive" every piece of software you read about.
- While one cannot completely avoid problems caused by bad programming, one can minimize the risk by not installing every bit of shareware, freeware, or beta code you read about just to "try it out." With application software, often less is more. If you depend on your Mac for your livelihood, reliability and stability are your primary concerns. Stick to reliable, proven applications shareware or freeware offerings that are highly rated on sites like MacUpdate and VersionTracker as well as commercial software from major software publishers.
- Educate yourself.
- As the preceding points have noted, many causes of data corruption and loss can be avoided by taking appropriate measures to protect your data and avoid the common causes of data corruption. Unfortunately, everything one needs to do so does not come in the same box with your Mac.
- Personal computers today are not much more advanced than automobiles were in the 1920's and '30s: owners of cars back then had to be part mechanic as well as driver. Modern cars still require regular maintenance, but they have evolved to the point that one can use them without needing a mechanic's skills. However, personal computing still has a way to go: you need to be prepared for troubleshooting (the mechanic role) as well as using (the driver role) your Mac. Likewise, computer hardware can fail unexpectedly, just as autos can break down, and usually at the worst possible moment.
- If your home or office has several Macs, a network, and the other peripherals normally associated with such setups printers, scanners, etc. then one is running their own data center, whether one realizes this or not. Educating yourself is helpful: our "Learning About Mac OS X" FAQ has a number of resources that you will find helpful including books, online training, and more.