Methods of payment Abuse

Checking the system for bad sectors

31.10.2022, 18:10

During disk operation, so-called bit sectors appear. These are cells that have stopped working for one reason or another. The problem is that the system may try to write information to the non-working cells. Everything is aggravated by the fact that it is difficult to read information from such cells, which means that the user may lose it. It should be said that such a problem is characteristic only for HDDs, when the new SSDs are already devoid of such a disadvantage. The usual hard drive is still popular and talk about its replacement by a "flash drive" is premature.

How to check HDD for bit sectors

How to find bit sectors in HDD? To do this, you can use a special utility, for example, fits badblocks. If you decide to check the root partition of the disk, it will be the right decision to boot LiveCD. All other partitions can be scanned in the installed OS.

Use the fdisk utility to view the desired disk partitions:

$ sudo fdisk -l /dev/sda1

Как проверить текст на битые секторы в Linux

If you prefer to use a graphical interface, use the Gparted program.

Select the desired disk from the drop-down list:

Как проверить текст на битые секторы в Linux

Let's check the /dev/sda2 partition with XFS file system. Apply badblocks.

The syntax is simple:

$ sudo badblocks опции /dev/name_disc_stripped

Consider all the options you might need:

Битые секторы

You can perform a normal check with the command:

$ sudo badblocks -v /dev/sda2 -o ~/bad_sectors.txt

The command is safe, you can run it without fear, it won't damage anything. You can run it on a mounted file system, but it is best to avoid it If the file system is unmounted, run the test using -n:

$ sudo badblocks -vn /dev/sda2 -o ~/bad_sectors.txt

Once the test is done, you have found bit blocks, report them to the file system so that it makes attempts to write information there.

Apply the fsck utility and the -l option:

f$ sck -l ~/bad_sectors.txt /dev/sda1

If you use Ext file system, for example Ext4, you can search for bit sectors and automatically register them in the file system with the e2fsck command:

$ sudo e2fsck -cfpv /dev/sda1

The -c option allows you to search for bad sectors and add them to the list, -f checks the file system, -p recovers corrupted data, and -v displays information in detail.