It is not safe to run Badblocks Howto

Put your plates through their paces: badblocks


Another tool for checking hard disk drives is the badblocks console tool. It should be present on almost all distributions and was developed with the aim of identifying bad sectors on mass storage devices. However, sometimes it is too late to use this tool. In addition, tests often take a long time with today's plate sizes.

Attention : Depending on the parameter, the test can lead to the loss of all data on the device.

The self-test with SMART is available for internal hard drives, but not for external data carriers and flash storage media such as USB sticks and memory cards. You need something else for these disks. Linux offers for the extensive surface test
the command line program badblocks, which is part of the e2fsprogs package and is installed by default in most distributions.

EnlargeOn the trail of errors with Badblocks

The tool performs an accurate surface test and outputs a list of the bad blocks. Depending on the desired test accuracy, there are three possible uses: To test mounted partitions whose data you do not want to lose, call the badblocks tool as root or with sudo using the command / sbin / badblocks -s -v / dev , where you replace the placeholder "" with the name of the device file, for example sda1 for the first partition on the first SATA or SCSI disk. The command performs a read-only test. You can only run a read and write test on partitions that have been detached. The command / sbin / badblocks -s -v -n / dev is used for this. The parameter "-n" indicates that only non-destructive read / write tests are carried out and that the stored data remain unchanged.

Make sure, however, that the partition is really unmounted, otherwise data can be lost. On the other hand, there is the call with the parameter “-w” instead of “-n”, which maltreats the disk with read-write tests and shreds the data in the process. However, this test gives very accurate results. Then the plate is swept empty, so the test is only suitable if reformatting or the courageous throw to the recycling container are pending anyway.

Important: bring your time. The tool is very accurate, and a full check takes time - hours if there are many errors. If you are not only looking for errors, but want to completely reformat a data carrier, you can also carry out an extensive test while formatting. This is always recommended if you are formatting a medium that has already been used.

With brand-new data carriers that have just come out of the box, you can save yourself the extra long test. Under Linux, you format data media with the various mkfs tools, such as mkfs.vfat for the FAT file system and mkfs.ext3 for ext3. The "-c" parameter carries out an extensive test before formatting. The command /sbin/mkfs.ext3 -c / dev / sdd1, for example, formats the partition / dev / sdd1 with ext3 and performs an extensive read test beforehand.

Behind this is also the badblocks program, which is called for these tests. Depending on the size and speed of the plate, the test can take a few hours. The advantage here is that badblocks transfers a list to mkfs and the bad blocks when formatting