View All R&D Articles

What Are Hard Drive Error Correction Codes (ECCs)?

October 28, 2022

Modern hard drives use error correction codes (ECCs) to make sure that data is readable, even when the write process is imperfect. 

Hard disk drives store information through magnetic charges, and while actuator heads (also called read/write heads) are extremely accurate, they occasionally “flip” a charge. In other words, the heads fail to write a charge or write a charge incorrectly.

Without error correction, data corruption would be extremely common. The solution: In addition to the user’s data, each sector of a hard drive includes information about the data, which allows incorrect data to be corrected by the hard drive controller before it is transmitted to the computer. 

How Error Correction Prevents Data Corruption

The simplest form of an ECC is a basic redundant write cycle: The same data is written two or more times. If one copy of the data has errors, the controller could correct it by referencing the other copies. 

While simple redundancy protects data, it isn’t practical at scale. If your hard drive wrote two copies of every file, only half of its total capacity would be usable, and writing a file would take twice as long.

Instead of writing multiple copies of data, ECCs use mathematical formulas that allow errors to be identified and corrected. Most modern hard drives use the Reed-Solomon error correction algorithm, which doesn’t require much storage space or processing power. The level of redundancy (and the number of tolerable errors) directly corresponds to the number of ECC bits included in each sector. 

When the hard drive reads data, the ECC informs the controller whether the data contains errors. As long as the number of errors is within the tolerable range of the ECC, they can be fixed.

This is an extreme simplification of ECC algorithms, but it demonstrates how a short code can improve accuracy. For a (much) more detailed explanation, we recommend reading’s introduction to error correction.

Does Hard Drive Error Correction Prevent Data Loss?

Error correction prevents data loss during the write process, but it has limitations: 

  • ECCs can only prevent a finite number of write errors. If the read/write heads are misaligned (for instance, due to a head crash), this limit will be quickly exceeded.
  • ECCs do not prevent all data corruption, particularly if a hard drive shuts down while writing data (or if software crashes during the write process).
  • Writing ECC bits requires processing power, and hard drive manufacturers limit the number of ECC bits to balance reliability with performance.

Most Data Storage Technologies Use ECCs

Error correcting codes are not unique to hard drives. Solid-state media (such as NAND memory) also uses ECCs, although solid-state drives and other flash devices may use different error correction algorithms (such as the BCH or Hamming algorithms).

While error correction is a vital tool for every type of data storage device, it’s not perfect. Data corruption can still occur — to protect important files, we recommend keeping at least three separate copies (including one off-site copy).

If you’ve lost data due to file corruption, hard drive failure, or for any other reason, we’re here to help. Contact our team at 1-800-237-4200 to schedule a free media evaluation or set up a case online.