SMART

Arch wiki

S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is a technology that most hdd and ssd have, which enables them to do a self-check and report whether they are in good shape or might be failing. Smart is found in the package smartmontools on most systems.

Check if a device can run SMART

Check which tests can be run on the device:

Run a test

If the test is not passed, you should immediately find another hard drive and backup your data, since the hdd is probably going to fail soon.

is this disk dying? question on stackexchange.

Badblocks

badblocks is a program that scan a partition, performing reading (and optionally writing) tests to determine whether any sector is faulty.

If the partition to scan hosts an ext2/3/4 filesystem, it's better to use fsck, since it will call badblocks with the correct block size that the filesystem is using.

The output file is a list of bad blocks on the disk. It can be used with the -l option of e2fsck or mke2fs to tell an ext2/3/4 filesystem not to use these blocks (see their manuals).

e2fsck

If you want to check a partition hosting a ext2/3/4 filesystem, it is suggested to use e2fsck. It will call badblocks with the correct options. Faulty blocks found this way are automatically added to a list of faulty blocks not to be used by the filesystem.

This will modify the filesystem, potentially corrupting files whose contents are in bad blocks, but these files are technically already corrupted, since they are in faulty blocks.

List bad blocks and their contents

As information, to print all the registered bad blocks of an ext drive, run dumpe2fs -b {partition}