{
    "mode": "man",
    "parameter": "badblocks",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/badblocks/8/json",
    "generated": "2026-05-30T07:08:23Z",
    "synopsis": "badblocks  [ -svwnfBX ] [ -b blocksize ] [ -c blocksatonce ] [ -d readdelayfactor ] [ -e\nmaxbadblocks ] [ -i inputfile ] [ -o outputfile ] [ -p numpasses ] [ -t  testpattern  ]\ndevice [ lastblock ] [ firstblock ]",
    "sections": {
        "NAME": {
            "content": "badblocks - search a device for bad blocks\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "badblocks  [ -svwnfBX ] [ -b blocksize ] [ -c blocksatonce ] [ -d readdelayfactor ] [ -e\nmaxbadblocks ] [ -i inputfile ] [ -o outputfile ] [ -p numpasses ] [ -t  testpattern  ]\ndevice [ lastblock ] [ firstblock ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "badblocks is used to search for bad blocks on a device (usually a disk partition).  device is\nthe special file corresponding to the device (e.g /dev/hdc1).  lastblock is the  last  block\nto  be  checked;  if  it is not specified, the last block on the device is used as a default.\nfirstblock is an optional parameter specifying the starting block number for the test, which\nallows  the  testing  to  start  in the middle of the disk.  If it is not specified the first\nblock on the disk is used as a default.\n\nImportant note: If the output of badblocks is going to be fed to the e2fsck  or  mke2fs  pro‐\ngrams,  it  is  important  that the block size is properly specified, since the block numbers\nwhich are generated are very dependent on the block size in use by the file system.  For this\nreason,  it is strongly recommended that users not run badblocks directly, but rather use the",
            "subsections": [
                {
                    "name": "-c",
                    "content": "",
                    "flag": "-c"
                }
            ]
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-b",
                    "content": "Specify the size of blocks in bytes.  The default is 1024.\n",
                    "flag": "-b"
                },
                {
                    "name": "-c",
                    "content": "is the number of blocks which are tested at a time.  The default is 64.\n",
                    "flag": "-c"
                },
                {
                    "name": "-d",
                    "content": "This parameter, if passed and non-zero, will cause bad blocks to sleep  between  reads\nif  there  were  no errors encountered in the read operation; the delay will be calcu‐\nlated as a percentage of the time it took for the read operation to be  performed.  In\nother  words, a value of 100 will cause each read to be delayed by the amount the pre‐\nvious read took, and a value of 200 by twice the amount.\n",
                    "flag": "-d"
                },
                {
                    "name": "-e",
                    "content": "Specify a maximum number of bad blocks before aborting the test.  The  default  is  0,\nmeaning the test will continue until the end of the test range is reached.\n",
                    "flag": "-e"
                },
                {
                    "name": "-f",
                    "content": "vice which is mounted, since either can cause the system to potentially  crash  and/or\ndamage  the file system even if it is mounted read-only.  This can be overridden using\nthe -f flag, but should almost never be used --- if you think you're smarter than  the\nbadblocks  program, you almost certainly aren't.  The only time when this option might\nbe safe to use is if the /etc/mtab file is incorrect,  and  the  device  really  isn't\nmounted.\n",
                    "flag": "-f"
                },
                {
                    "name": "-i",
                    "content": "Read  a  list of already existing known bad blocks.  Badblocks will skip testing these\nblocks since they are known to be bad.  If inputfile is specified as  \"-\",  the  list\nwill be read from the standard input.  Blocks listed in this list will be omitted from\nthe list of new bad blocks produced on the standard output or in the output file.  The\n-b  option  of dumpe2fs(8) can be used to retrieve the list of blocks currently marked\nbad on an existing file system, in a format suitable for use with this option.\n",
                    "flag": "-i"
                },
                {
                    "name": "-n",
                    "content": "is  done.   This  option must not be combined with the -w option, as they are mutually\nexclusive.\n",
                    "flag": "-n"
                },
                {
                    "name": "-o",
                    "content": "Write the list of bad blocks to the specified file.  Without  this  option,  badblocks\ndisplays the list on its standard output.  The format of this file is suitable for use\nby the -l option in e2fsck(8) or mke2fs(8).\n",
                    "flag": "-o"
                },
                {
                    "name": "-p",
                    "content": "Repeat scanning the disk until there are no new blocks discovered in  numpasses  con‐\nsecutive scans of the disk.  Default is 0, meaning badblocks will exit after the first\npass.\n",
                    "flag": "-p"
                },
                {
                    "name": "-s",
                    "content": "rent  badblocks  pass  over the disk.  Note that badblocks may do multiple test passes\nover the disk, in particular if the -p or -w option is requested by the user.\n",
                    "flag": "-s"
                },
                {
                    "name": "-t",
                    "content": "Specify a test pattern to be read (and written) to disk blocks.   The testpattern may\neither  be  a numeric value between 0 and ULONGMAX-1 inclusive, or the word \"random\",\nwhich specifies that the block should be  filled  with  a  random  bit  pattern.   For\nread/write (-w) and non-destructive (-n) modes, one or more test patterns may be spec‐\nified by specifying the -t option for each test pattern desired.  For  read-only  mode\nonly  a single pattern may be specified and it may not be \"random\".  Read-only testing\nwith a pattern assumes that the specified pattern has previously been written  to  the\ndisk  -  if not, large numbers of blocks will fail verification.  If multiple patterns\nare specified then all blocks will be tested with one pattern before proceeding to the\nnext pattern.\n",
                    "flag": "-t"
                },
                {
                    "name": "-v",
                    "content": "tions to stderr.\n",
                    "flag": "-v"
                },
                {
                    "name": "-w",
                    "content": "patterns  (0xaa,  0x55,  0xff, 0x00) on every block of the device, reading every block\nand comparing the contents.  This option may not be combined with the  -n  option,  as\nthey are mutually exclusive.\n",
                    "flag": "-w"
                },
                {
                    "name": "-B",
                    "content": "",
                    "flag": "-B"
                },
                {
                    "name": "-X",
                    "content": "mode in-use device safety check.\n",
                    "flag": "-X"
                }
            ]
        },
        "WARNING": {
            "content": "Never use the -w option on a device containing an existing file system.  This  option  erases\ndata!  If you want to do write-mode testing on an existing file system, use the -n option in‐\nstead.  It is slower, but it will preserve your data.\n\nThe -e option will cause badblocks to output a possibly incomplete list of bad blocks. There‐\nfore  it  is recommended to use it only when one wants to know if there are any bad blocks at\nall on the device, and not when the list of bad blocks is wanted.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "badblocks was written by Remy Card <Remy.Card@linux.org>.   Current  maintainer  is  Theodore\nTs'o  <tytso@alum.mit.edu>.   Non-destructive  read/write  test  implemented by David Beattie\n<dbeattie@softhome.net>.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "badblocks is part of the e2fsprogs package and  is  available  from  http://e2fsprogs.source‐\nforge.net.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "e2fsck(8), mke2fs(8)\n\n\n\nE2fsprogs version 1.46.5                    December 2021                               BADBLOCKS(8)",
            "subsections": []
        }
    },
    "summary": "badblocks - search a device for bad blocks",
    "flags": [
        {
            "flag": "-b",
            "long": null,
            "arg": null,
            "description": "Specify the size of blocks in bytes. The default is 1024."
        },
        {
            "flag": "-c",
            "long": null,
            "arg": null,
            "description": "is the number of blocks which are tested at a time. The default is 64."
        },
        {
            "flag": "-d",
            "long": null,
            "arg": null,
            "description": "This parameter, if passed and non-zero, will cause bad blocks to sleep between reads if there were no errors encountered in the read operation; the delay will be calcu‐ lated as a percentage of the time it took for the read operation to be performed. In other words, a value of 100 will cause each read to be delayed by the amount the pre‐ vious read took, and a value of 200 by twice the amount."
        },
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": "Specify a maximum number of bad blocks before aborting the test. The default is 0, meaning the test will continue until the end of the test range is reached."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": "vice which is mounted, since either can cause the system to potentially crash and/or damage the file system even if it is mounted read-only. This can be overridden using the -f flag, but should almost never be used --- if you think you're smarter than the badblocks program, you almost certainly aren't. The only time when this option might be safe to use is if the /etc/mtab file is incorrect, and the device really isn't mounted."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": "Read a list of already existing known bad blocks. Badblocks will skip testing these blocks since they are known to be bad. If inputfile is specified as \"-\", the list will be read from the standard input. Blocks listed in this list will be omitted from the list of new bad blocks produced on the standard output or in the output file. The -b option of dumpe2fs(8) can be used to retrieve the list of blocks currently marked bad on an existing file system, in a format suitable for use with this option."
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": "is done. This option must not be combined with the -w option, as they are mutually exclusive."
        },
        {
            "flag": "-o",
            "long": null,
            "arg": null,
            "description": "Write the list of bad blocks to the specified file. Without this option, badblocks displays the list on its standard output. The format of this file is suitable for use by the -l option in e2fsck(8) or mke2fs(8)."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "Repeat scanning the disk until there are no new blocks discovered in numpasses con‐ secutive scans of the disk. Default is 0, meaning badblocks will exit after the first pass."
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": "rent badblocks pass over the disk. Note that badblocks may do multiple test passes over the disk, in particular if the -p or -w option is requested by the user."
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "Specify a test pattern to be read (and written) to disk blocks. The testpattern may either be a numeric value between 0 and ULONGMAX-1 inclusive, or the word \"random\", which specifies that the block should be filled with a random bit pattern. For read/write (-w) and non-destructive (-n) modes, one or more test patterns may be spec‐ ified by specifying the -t option for each test pattern desired. For read-only mode only a single pattern may be specified and it may not be \"random\". Read-only testing with a pattern assumes that the specified pattern has previously been written to the disk - if not, large numbers of blocks will fail verification. If multiple patterns are specified then all blocks will be tested with one pattern before proceeding to the next pattern."
        },
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": "tions to stderr."
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": "patterns (0xaa, 0x55, 0xff, 0x00) on every block of the device, reading every block and comparing the contents. This option may not be combined with the -n option, as they are mutually exclusive."
        },
        {
            "flag": "-B",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-X",
            "long": null,
            "arg": null,
            "description": "mode in-use device safety check."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "e2fsck",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/e2fsck/8/json"
        },
        {
            "name": "mke2fs",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/mke2fs/8/json"
        }
    ]
}