LINFO            

Bad Blocks Definition



Bad blocks, also called bad sectors, are sections of magnetic storage media (i.e., hard disks and floppy disks) that cannot be reliably used for storing and retrieving data.

A block is a uniform unit of the storage media whose size is determined at the time of high-level formatting (i.e., creation of a filesystem). If the mke2fs command (which is used to create the standard Linux ext2 and ext3 filesystems) is used, valid block size values are 1024, 2048 or 4096 bytes. The default block size on a typical Red Hat 9 Linux installation is 4096 bytes.

New disks are given a low level formatting at the factory, which consists of writing the track and sector markers on the blank magnetic media. If one of these new sectors cannot be read or write correctly, then it is marked as bad or invalid, and a spare sector is used to replace it. Similarly, if, in use, a block does not record correctly after several attempts, it is marked bad, and is remapped to a spare defect-free block.

The list of bad blocks is provided to the filesystem, which stores it in a special file and remembers not to use those blocks. This relieves the operating system of the task of keeping track of bad blocks and ensures that the computer only sees a well-behaved, defect-free device. The e2fsck command, which is used to check ext2 and ext3 filesystems, automates the process of giving the list to the filesystem and thus is highly reliable.

The badblocks program is used for checking for bad blocks is on Unix-like operating systems. This program should only be used directly when checking a blank partition or a filesystem other than ext2 or ext3. When checking an ext2 or ext3 filesystem partition, e2fsck should be used, which runs badblocks in the background. Some Microsoft Windows operating systems as well as MS-DOS contain a program called ScanDisk to check for bad blocks.






Created July 5, 2005.
Copyright © 2005 The Linux Information Project. All Rights Reserved.