A bad block is a damaged area of magnetic storage media that cannot reliably be used to store and retrieve data.
In magnetic storage media, bad blocks can happen when a location on a hard disk is defective or when the cyclic redundancy check (CRC) for a particular storage block does not match the data read by the disk. The best way to fix a file that has been affected by a bad block is to write over the original file. This will cause the hard disk to spare the bad block, or fix the CRC and/or data.
Managing bad blocks is an important part of improving the reliability and endurance of NAND flash drives. While flash isn't a magnetic medium, it can also experience bad blocks. Blocks can become worn from use, making them unusable after a certain number of write and erase cycles. To extend the life of a solid-state device, the software that manages the NAND device implements a wear-leveling algorithm to ensure that no block has excessive use compared with the other blocks. Before reading from or writing to a NAND device, the software will check the device's Bad Block Table (BBT) to avoid bad blocks. There are two types of BBTs -- NAND-resident BBTs, which are preserved across system boots and RAM-resident BBTs, which must be re-created each time the system is booted.