Disk test for broken sectors in Ubuntu

BadBlocks = lost data. You can check and correct them in a couple of commands.

See which disc we will check:

sudo fdisk -l

Knowing the disk, we launch the badblocks utility:

sudo badblocks -v /dev/sdb1 > badsectors.txt

What do the parameters mean:

We specify the following parameters for verification:

  • -v — detailed conclusion of information on the audit results,
  • /dev/sdb1 — section to be audited,
  • badsectors.txt — in this file we save information about broken sectors, which we will then work with..

Two utilities are usually used for fixing:

  • e2fsck – for file systems ext2, ext3, ext4,
  • fsck – for all others who are not ext*

We are launching:

sudo e2fsck -l badsectors.txt /dev/sdb1

or:

sudo fsck -l badsectors.txt /dev/sdb1

… and basically everything!

P.S. I recommend doing this regularly 🙂

Upd. Using smartmontools:

I saw another utility that shows SMART data (Self-Diagnostic Winchester Data):

sudo apt-get install smartmontools
sudo smartctl -H /dev/sdb1

other parameters:

  • -a or –all – show all data about the disk,
  • -x or –xall – to see other parameters of the drive

About: Morozov Dmitry

My specialisation is software engineer. I am 35 years old and have been working in the IT field for over 15 years. I have accumulated experience in programming, project management, training and administration.