Forrest logo
back to the badblocks tool

badblocks:tldr:89d11

badblocks: Search an unmounted disk for bad blocks with a destructive write test and show verbose status.
$ sudo badblocks -svw ${-dev-sdX}
try on your machine

This command uses the "badblocks" command in Linux with the following options and parameters:

  1. "sudo": It runs the subsequent command with root/administrator privileges. This is necessary because the "badblocks" command requires elevated privileges to access and analyze the storage device.

  2. "badblocks": It is a Linux command used to check for bad blocks on a storage device such as a hard disk drive or solid-state drive. It reads or writes specific patterns to the device to identify any defective blocks.

  3. "-svw": These are options passed to the "badblocks" command.

    • "-s" shows the progress of the badblock checking process.
    • "-v" increases verbosity, providing more detailed output.
    • "-w" performs a non-destructive read-write test, which writes a specific pattern to each block, reads it back, and checks for errors. This test can be time-consuming.
  4. "${-dev-sdX}": It is a parameter representing the device name or path of the storage device to be examined. However, there is a typo in the command you shared. It should be "${DEV}sdX" instead of "${-dev-sdX}". The actual correct device name or path should replace "sdX". For example, if you want to check "sda", it will be "${DEV}sda".

Overall, this command allows you to check a storage device for bad blocks using the "badblocks" command with specific options for progress indication, verbosity, and non-destructive read-write testing.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the badblocks tool