Forrest logo
back to the badblocks tool

badblocks:tldr:c8b78

badblocks: Search an unmounted disk for bad blocks with a non-destructive read-write test.
$ sudo badblocks -n ${-dev-sdX}
try on your machine

This command utilizes the badblocks utility, which is used to search for bad blocks on a storage device such as a hard disk. Here's a breakdown of each part of the command:

  • sudo: This is a command that allows the user to run a program with administrative privileges. It is usually required for system-level tasks.

  • badblocks: This is the command itself. It is used to scan for bad blocks on a storage device. By default, it reads from the device, performs a non-destructive read-write test, and displays a list of bad blocks found.

  • -n: This is an option for the badblocks command. The -n option specifies that it should perform a non-destructive read-write test. This test writes patterns of data to the blocks and then reads them to check for errors. It does not overwrite the existing data on the device.

  • ${-dev-sdX}: This is a placeholder for the device name of the storage device you want to scan. You need to replace ${-dev-sdX} with the actual device name, such as /dev/sda or /dev/sdb. It is important to be cautious while using this command, as specifying the wrong device can lead to data loss.

In summary, this command prompts the user to scan a storage device for bad blocks using the badblocks utility with a non-destructive read-write test. Remember to replace ${-dev-sdX} with the appropriate device name before executing the command.

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