I have a RAID 1 of 2 hard drives managed with mdadm. Today, one of them failed. I figured out that this is because of bad sectors in /dev/sdb. According to badblocks, these sectors are affected: 1028, 1029, 1030, 1031. In /dev/sdb1 (the only partition on the hard drive), they are sectors 4, 5, 6, 7. I performed a read-only test.

After googling the problem, I found out that you can instruct a file system to cope with bad blocks. But what do you do if the affected region isn't used directly by any file system but by a RAID manager instead?

I guess that in my case I could simply move the partition a bit to the right. But what would you do if the fault was somewhere in the middle of the drive? Is moving the partition a bit to the right the proper solution for my problem?

  • The more interesting question is why you actually see badblocks, because on most modern hard drives, bad sectors get mapped away transparently. So even if you tell Linux to ignore these blocks, it won't help. Did you inspect the SMART values on the drives? – dirkt Dec 5 '18 at 8:37
  • @dirkt I used badblocks in read-only mode several times. It always found the same bad blocks. When I used it in write mode, it didn't find any. I then dded binary zeros over the beginning of the drive and ran badblocks in read-only mode again. It didn't find any bad blocks. These are the SMART values of the drive: pastebin.com/Lnk15KuD I find it particularly confusing that it says 0 bad sectors there. To me, this sounds like that the drive isn't even compensating for bad sectors internally. – UTF-8 Dec 5 '18 at 11:41
  • Not finding bad blocks in write mode/after writing zeros suggests the harddisk remapped the sectors, or that it was able to correct the problem somehow during the write. A reallocated sector count of zero suggests the latter. In any case, now you won't need to tell the file system about the bad blocks, because they are no longer bad. You may have to reinitialize the RAID info part, though, and I wouldn't store any important data on this disk. – dirkt Dec 5 '18 at 11:58
  • @dirkt Do you mean because the disk might fail again soon or because of undetected data corruption? Is the latter made more likely by the disk having experienced bad blocks? Because I don't see much of a problem with the former as there is another copy on the data on /dev/sda, of course. – UTF-8 Dec 6 '18 at 9:34
  • Because it might fail again soon. The harddisk detected the problem just fine, so I'm not sure what you mean by "undetected data corruption". – dirkt Dec 6 '18 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.