Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to to check / repair my hard drive but I don't know a way how to see the number of bad sectors on my hard drive.

P.S. It looks like my hard drive will die soon :-(

share|improve this question
Please answer the question. I would also like to know if there are badblocks marked in an ext4 file-system – Robert Vila Nov 9 '12 at 5:02
up vote 8 down vote accepted

There are two ways to detect bad sectors in Linux: you can use the disk utility (gui), or you can use the badblocks command to check your hard disk for bad sectors:

sudo badblocks -v /dev/{device}

That should answer the question but for anyone else interested in how to mark them it can be done with 2 simple commands...

You add the bad blocks to a file...

sudo badblocks /dev/sdb > {/dir/to/filename}

and then tell fsck to mark these as unusable with ...

sudo fsck -l {/dir/to/filename} /dev/{device}
share|improve this answer
It seems that e2fsck has a -c option which calls badblocks itself and takes care of the block size. One apparently has to be really careful that those match if you do it your way. – Martin Ueding Jul 21 '14 at 14:39
This use of badblocks+fsck to mark bad blocks could be dangerous. From badblocks man page: "Important note: If the output of badblocks is going to be fed to the e2fsck or mke2fs programs, it is important that the block size is properly specified, since the block numbers which are generated are very dependent on the block size in use by the filesystem. For this reason, it is strongly recommended that users not run badblocks directly, but rather use the -c option of the e2fsck and mke2fs programs." See @john-mehorter answer. – sierrasdetandil Jan 17 '15 at 18:58

Use fsck.ext3 (e2fsck) for instance and use the -cc option

-c     This option causes e2fsck to use badblocks(8) program to do a read-only scan of the device in  order  to  find  any  bad
          blocks.   If  any  bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a
          file or directory.  If this option is specified twice, then the bad block scan will  be  done  using  a  non-destructive
          read-write test.`

fsck -cc /dev/sda1

share|improve this answer
I have read this several times the last years but I don't know what is a non-destructive test. It doesn't change anything in the disk? Is it informative only? – Robert Vila Nov 9 '12 at 5:16
I assume that it will try to write in each block, but write the original data back again. – Martin Ueding Jul 21 '14 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.