\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Badblocks is a tool for detecting bad blocks in your hard disk.

Usage

The following will write to every block and read back to identify the number of bad blocks.

This is a destructive test. ETA is approximately 1 day per 4 terabytes.

badblocks -wsv -b 4096 /dev/sdg
  • -w do a destructive write test
  • -s show progress
  • -v verbose
  • -b num block size. Use 4096 typically.
  • -p num do num iterations. Typically 1 is sufficient.
  • -t test_pattern Test pattern. Select from [random,

To save the list of bad blocks, you need to run e2fsck or mkfs.ext4:

sudo e2fsck -fcck /dev/device
  • -f force check
  • -cc non-destructive write test
  • -k add bad blocks to bad blocks list
mkfs.ext4 -cc /dev/device

Resources