Open In App

badblocks command in Linux with examples

badblock command in Linux is used to search for bad blocks (block of memory which has been corrupted and can no longer be used reliably) in a device. It is by default set to run in non-destructive read-only mode.

Syntax:



badblocks [-b block_size] [-i input_file] [-o output_file] [-svwnf]
          [-c blocks_at_once] [-d delay_factor_between_reads] [-e max_bad_blocks]
          [-p num_passes] [-t test_pattern [-t test_pattern [...]]]
          device [last_block [first_block]]

Options:

Specify blocks to test:

  1. last block: It can be specified by passing the last block as an option after device name. It would test blocks from the first block to the specified last block.

    Example:

    sudo badblocks -s /dev/sdb1 1000

  2. first block: It can be specified by passing the starting block number to test as an option after last block.

    Example:

    sudo badblocks -s /dev/sdb1 5000 100

Article Tags :