How to Check Bad Sectors or Bad Blocks on Hard Disk in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

8 Responses

  1. Virender Sood says:

    please let me know how to remove read only error from the flash drive

  2. Anon. says:

    So much fail. None of these will ever work for SSDs.

    • Aaron Kili says:

      @Anon

      I presume you have tasted the methods above with SSDs, and may you give us an explanation for your conclusion. That will help us understand better, why you have said so and probably find other ways to deal with bad sectors on SSDs.

  3. HankB says:

    So much fail in this article. Modern drives remap bad sectors so the bad blocks command will not detect them. Smartmontools are better but you need to examine individual readings to determine drive health.

    I have a 2 TB that developed about 2500 remapped sectors before drive health changed from good.

    • Aaron Kili says:

      @HankB

      Good concern here and thanks for letting us know about the behavior of modern disks while detecting bad sectors in relation to badblocks utility, there are two methods offered in the article, a user can employ the two approaches to determine disk health(badblocks for older disks and smartmontools for modern disks as you have explained).

      Again, smartctl which controls S.M.A.R.T system has multiple other options that you can try as per the descriptions in the man page, if you suspect a critical issue with your disk drive, you may probably want to check individual partitions for better diagnostics.

  4. Greg says:

    I see the first method is Read Only, to be clear, the second method is a “Passive” (Read Only) Check as well? I would want to minimize unnecessary Read/Writes to an SSD.

    If a bad sector is found, will these methods try ‘testing’ the sector?

    Thanks.

    • Aaron Kili says:

      @Greg

      For the case of badblocks utility you can enable write-mode test to all sectors by using the -w. This option allows badblocks command to scan for bad sectors by writing some patterns such as 0xaa, 0x55, 0xff, 0x00 on every block of the device, reading every sector and comparing the contents.

      However, do not use the -w flag on a disk with an existing file system, you can read more about this warning from the badblocks man page.

      Then, smartctl utility will print out an error or “failed” overall health test result after S.M.A.R.T tests all bad sector to show an imminent hardware failure.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?